Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv_cpu_info fails on Darwin ARM64 #2911

Closed
Keno opened this issue Jul 11, 2020 · 6 comments
Closed

uv_cpu_info fails on Darwin ARM64 #2911

Keno opened this issue Jul 11, 2020 · 6 comments
Labels

Comments

@Keno
Copy link
Contributor

Keno commented Jul 11, 2020

Darwin ARM64 appears to be missing the hw.cpufrequency sysctl, causing uv_cpu_info to fail.
I'm thinking this might just be an oversight, so I've submitted a ticket with Apple (FB7917120),
but I figured it would be worth filing an issue here as well to track the issue.

@bnoordhuis
Copy link
Member

Related: nodejs/node#34238 - that PR is currently floating a libuv patch to work around this issue.

bnoordhuis added a commit to bnoordhuis/libuv that referenced this issue Jul 11, 2020
The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Fixes: libuv#2911
@bnoordhuis
Copy link
Member

I've opened #2912 with a possible workaround. Can you take a look?

cc @evanlucas

evanlucas added a commit to evanlucas/libuv that referenced this issue Jul 14, 2020
This switches uv_cpu_info from using sysctlbyname to
using IOKit to get the speed of the processors.
macOS on ARM does not currently have the hw.cpufrequency
sysctl. We are able to reliable get the clock frequency
on all architectures by using IOKit.

Fixes: libuv#2911
@evanlucas
Copy link
Contributor

I opened #2914 in addition.

cc @bnoordhuis @Keno

@stale stale bot added the stale label Aug 4, 2020
@libuv libuv deleted a comment from stale bot Aug 4, 2020
@cjihrig
Copy link
Contributor

cjihrig commented Aug 4, 2020

Are there any other known issues on Apple Silicon? In other words, do we think it's OK to claim support in the next release?

@Keno
Copy link
Contributor Author

Keno commented Aug 4, 2020

No known issues on our end with libuv, though our test suite is not 100% functional yet on Apple Silicon, so we may have missed something.

@evanlucas
Copy link
Contributor

With V8 8.5, node's full test suite passes as well. From what I've seen, this was the only thing that didn't work.

JeffroMF pushed a commit to JeffroMF/libuv that referenced this issue May 16, 2022
This switches uv_cpu_info from using sysctlbyname to
using IOKit to get the speed of the processors.
macOS on ARM does not currently have the hw.cpufrequency
sysctl. We are able to reliable get the clock frequency
on all architectures by using IOKit.

Fixes: libuv#2911
PR-URL: libuv#2914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
vtjnash pushed a commit to vtjnash/libuv that referenced this issue Jul 11, 2022
The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Fixes: libuv#2911
vtjnash pushed a commit to vtjnash/libuv that referenced this issue Jul 11, 2022
The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Refs: libuv#2912
Fixes: libuv#2911
vtjnash added a commit to JuliaLang/libuv that referenced this issue Jul 12, 2022
This reverts commit 87f0765.

This has been reported to be unnecessary, and also returns the wrong
answer (off by exactly 100x), so it is not particularly useful.

This also reverts the bugfixes to the original PR:

Revert "darwin: fix iOS compilation and functionality"
This reverts commit 1addf9b.

Revert "macos: fix the cfdata length in uv__get_cpu_speed (libuv#3356)"
This reverts commit 1e70749.

Revert "darwin: fix -Wsometimes-uninitialized warning"
This reverts commit 6085bce.

Revert "macos: fix memleaks in uv__get_cpu_speed"
This reverts commit d2482ae.

Fixes: libuv#3642

Then work around missing hw.cpufrequency sysctl:

The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Then, we can simply hard-code the sysctl hw.cpufrequency for ARM64 to
the expected value, so users won't notice.

Refs: libuv#2912
Fixes: libuv#2911

(cherry picked from the sequence of commits:
6868d80,
eb645ea,
6c65326,
25f9730)
vtjnash added a commit to JuliaLang/libuv that referenced this issue Jul 12, 2022
This reverts commit 87f0765.

This has been reported to be unnecessary, and also returns the wrong
answer (off by exactly 100x), so it is not particularly useful.

This also reverts the bugfixes to the original PR:

Revert "darwin: fix iOS compilation and functionality"
This reverts commit 1addf9b.

Revert "macos: fix the cfdata length in uv__get_cpu_speed (libuv#3356)"
This reverts commit 1e70749.

Revert "darwin: fix -Wsometimes-uninitialized warning"
This reverts commit 6085bce.

Revert "macos: fix memleaks in uv__get_cpu_speed"
This reverts commit d2482ae.

Fixes: libuv#3642

Then work around missing hw.cpufrequency sysctl:

The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Then, we can simply hard-code the sysctl hw.cpufrequency for ARM64 to
the expected value, so users won't notice.

Refs: libuv#2912
Fixes: libuv#2911

(cherry picked from the sequence of commits:
6868d80,
eb645ea,
6c65326,
25f9730)
vtjnash added a commit to JuliaLang/libuv that referenced this issue Aug 1, 2022
This reverts commit 87f0765.

This has been reported to be unnecessary, and also returns the wrong
answer (off by exactly 100x), so it is not particularly useful.

This also reverts the bugfixes to the original PR:

Revert "darwin: fix iOS compilation and functionality"
This reverts commit 1addf9b.

Revert "macos: fix the cfdata length in uv__get_cpu_speed (libuv#3356)"
This reverts commit 1e70749.

Revert "darwin: fix -Wsometimes-uninitialized warning"
This reverts commit 6085bce.

Revert "macos: fix memleaks in uv__get_cpu_speed"
This reverts commit d2482ae.

Fixes: libuv#3642

Then work around missing hw.cpufrequency sysctl:

The hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon) but it should be okay to report 0, that's why
we ignore errors from this commit onward.

Then, we can simply hard-code the sysctl hw.cpufrequency for ARM64 to
the expected value, so users won't notice.

Refs: libuv#2912
Fixes: libuv#2911

(cherry picked from the sequence of commits:
6868d80,
eb645ea,
6c65326,
25f9730)
vtjnash added a commit that referenced this issue Nov 8, 2022
This reverts commit 87f0765 and
implements a work-around instead. This has been reported to be
unnecessary, and also returns the wrong answer (off by exactly 100x),
so it is not particularly useful.

This also reverts the bugfixes to the original PR:

Revert "darwin: fix iOS compilation and functionality"
This reverts commit 1addf9b.

Revert "macos: fix the cfdata length in uv__get_cpu_speed (#3356)"
This reverts commit 1e70749.

Revert "darwin: fix -Wsometimes-uninitialized warning"
This reverts commit 6085bce.

Revert "macos: fix memleaks in uv__get_cpu_speed"
This reverts commit d2482ae.

The expected behavior on failure to read this info is to report 0 (for
example
https://github.com/libuv/libuv/blob/8975c05d199558b0cc2e98f26ce33c6090d1
d7a1/src/unix/linux.c#L834), which is which was not the case before
this PR for macos.

However hw.cpufrequency sysctl seems to be missing on darwin/arm64
(Apple Silicon), so we instead hardcode a plausible value. This value
matches what the mach kernel will report when running Rosetta apps.

Fixes: #3642
Fixes: #2911
Refs: #2912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants