-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Make std::thread::available_concurrency
support process-limited number of CPUs
#89310
Make std::thread::available_concurrency
support process-limited number of CPUs
#89310
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
std::thread::available_concurrency
support process-limited number of CPUs
This comment has been minimized.
This comment has been minimized.
d6affdc
to
33e4614
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared this against num_cpus/linux.rs
, and this looks good!
33e4614
to
433439e
Compare
I believe this PR should be ready to be merged? |
@bors r+ |
📌 Commit 433439e has been approved by |
…affinity, r=m-ou-se Make `std::thread::available_concurrency` support process-limited number of CPUs Use `libc::sched_getaffinity` and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited via `taskset` or similar. This also covers cgroup cpusets.
…affinity, r=m-ou-se Make `std::thread::available_concurrency` support process-limited number of CPUs Use `libc::sched_getaffinity` and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited via `taskset` or similar. This also covers cgroup cpusets.
Fixed the missing macros on Android in rust-lang/libc#2470 . Once that goes in, I'll do a libc release and update. |
433439e
to
645e46e
Compare
@bors r=m-ou-se |
This comment has been minimized.
This comment has been minimized.
…r of CPUs Use libc::sched_getaffinity and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited via taskset or similar.
645e46e
to
7c9611d
Compare
Updated to libc 0.2.106 which includes the fix for the issue that broke CI on macOS. @bors r=m-ou-se |
📌 Commit 7c9611d has been approved by |
⌛ Testing commit 7c9611d with merge bd73825db1627e06ead2c3e17513f3aaa9b2c46d... |
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 7c9611d has been approved by |
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (fecfc0e): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Use
libc::sched_getaffinity
and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited viataskset
or similar.This also covers cgroup cpusets.