Skip to content

darwin: use IOKit for uv_cpu_info - #2914

Closed
evanlucas wants to merge 3 commits into
libuv:v1.xfrom
evanlucas:iokitcpuspeed
Closed

evanlucas wants to merge 3 commits into
libuv:v1.xfrom
evanlucas:iokitcpuspeed

Conversation

@evanlucas

Copy link
Copy Markdown
Contributor

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: #2911

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

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments but the basic concept looks good to me!

Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
Comment thread src/unix/darwin.c Outdated
@evanlucas

Copy link
Copy Markdown
Contributor Author

Okay, I believe I've addressed your comments @bnoordhuis. Thanks for the feedback!

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Evan! CI: https://ci.nodejs.org/job/libuv-test-commit/1949/

The only potential snag I see is that repeated calls to uv_cpu_info() become too slow now due to the repeated dlopen/dlsym/dlclose calls, but we'll change it to lazy-load them once if that turns out to be an issue.

Comment thread src/unix/darwin.c Outdated
bnoordhuis pushed a commit that referenced this pull request Aug 4, 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: #2911
PR-URL: #2914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@bnoordhuis

Copy link
Copy Markdown
Member

Landed in 87f0765, thanks Evan!

@bnoordhuis bnoordhuis closed this Aug 4, 2020
JeffroMF pushed a commit to JeffroMF/libuv that referenced this pull request 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>
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Jul 23, 2025
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/libuv#2911
PR-URL: libuv/libuv#2914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
liujinye-sys pushed a commit to open-vela/apps_system_libuv that referenced this pull request Dec 16, 2025
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/libuv#2911
PR-URL: libuv/libuv#2914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv_cpu_info fails on Darwin ARM64

2 participants