-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Use available_parallelism
instead of num_cpus
#10427
Conversation
`std::thread::available_parallelism` has been stabilized since 1.59.0. Also, we don't want to block timing data output, so if parallelism data is not available the table will display `ncpu=n/a` instead.
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
let jobs = jobs.or(cfg.jobs).unwrap_or(::num_cpus::get() as u32); | ||
let jobs = match jobs.or(cfg.jobs) { | ||
Some(j) => j, | ||
None => available_parallelism()?.get() as u32, |
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.
Could the error-propagation here have some context indicating what the error is? (e.g. something like "failed to determine the amount of parallelism available")
I get the impression that |
Thanks for the review. I think @ehuss is right. Ref: |
@ehuss @weihanglo |
@bors r+ |
📌 Commit 4f706ae has been approved by |
☀️ Test successful - checks-actions |
Update cargo 11 commits in 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34..65c82664263feddc5fe2d424be0993c28d46377a 2022-02-28 19:29:07 +0000 to 2022-03-09 02:32:56 +0000 - Remove remaining 2 warn(clippy::*) instances (rust-lang/cargo#10438) - Use `available_parallelism` instead of `num_cpus` (rust-lang/cargo#10427) - Wait up to one second while waiting for curl (rust-lang/cargo#10456) - Improve code coverage (rust-lang/cargo#10460) - Don't recommend leaking tokens into the console history (rust-lang/cargo#10458) - fix some typos (rust-lang/cargo#10454) - Use `extend` instead of `push`ing in a loop (rust-lang/cargo#10453) - Use locked_version more (rust-lang/cargo#10449) - Disable dependabot (rust-lang/cargo#10443) - Update git2 dependencies (rust-lang/cargo#10442) - Stop gating stable features (rust-lang/cargo#10434)
Update cargo 11 commits in 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34..65c82664263feddc5fe2d424be0993c28d46377a 2022-02-28 19:29:07 +0000 to 2022-03-09 02:32:56 +0000 - Remove remaining 2 warn(clippy::*) instances (rust-lang/cargo#10438) - Use `available_parallelism` instead of `num_cpus` (rust-lang/cargo#10427) - Wait up to one second while waiting for curl (rust-lang/cargo#10456) - Improve code coverage (rust-lang/cargo#10460) - Don't recommend leaking tokens into the console history (rust-lang/cargo#10458) - fix some typos (rust-lang/cargo#10454) - Use `extend` instead of `push`ing in a loop (rust-lang/cargo#10453) - Use locked_version more (rust-lang/cargo#10449) - Disable dependabot (rust-lang/cargo#10443) - Update git2 dependencies (rust-lang/cargo#10442) - Stop gating stable features (rust-lang/cargo#10434)
[beta] Revert #10427: switch from num_cpus This temporarily reverts #10427 (Use available_parallelism instead of num_cpus) per the discussion at rust-lang/rust#97549. `available_parallelism` does not handle cgroups v1 on Linux unlike num_cpus. I am concerned that this potentially affects a significant percentage of users. For example, Docker just added cgroups v2 support last year. Various Linux distributions have only recently switched to it as the default. The following is what I can find on the web: * Fedora (since 31) * Arch Linux (since April 2021) * openSUSE Tumbleweed (since c. 2021) * Debian GNU/Linux (since 11) * Ubuntu (since 21.10) * RHEL and RHEL-like distributions (since 9) This also appears to affect CircleCI. The consequence is that Cargo ends up using too much parallelism and can run out of memory. I'm not sure what to do about 1.63. If std adds support for cgroups v1, then I don't think there is anything to do there. Otherwise I think we should revert similarly if that doesn't happen.
Status: blocked on rust-lang/rust#92697
Just realized that we can drop one dependency 🎉
Also, we don't want to block timing data output, so if parallelism data is not available, the table will display
ncpu=n/a
instead.