-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add an option to run rustbuild on low priority on Windows and Unix #42069
Conversation
This is a resurrection of rust-lang#40776, combining their Windows setup with an additional setup on Unix to set the program group's niceness to +10 (low-but-not-lowest priority) when the `low_priority` option is on.
(rust_highfive has picked a reviewer for you, use r? to override) |
nice |
Thanks for the PR @QuietMisdreavus, we'll make sure @alexcrichton or another reviewer gets to this soon. |
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.
Looks great to me, thanks @QuietMisdreavus!
src/bootstrap/lib.rs
Outdated
//apparently glibc defines their own enum for this parameter, in a different type | ||
#[cfg(not(any(target_env = "musl", target_env = "musleabi", target_env = "musleabihf", | ||
target_os = "emscripten", target_arch = "mips", target_arch = "mipsel")))] | ||
const PRIO_PGRP: libc::c_uint = libc::PRIO_PGRP as libc::c_uint; |
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.
It looks like this is defined as
pub const PRIO_PGRP: ::c_int = 1;
for all platforms, is the #[cfg]
here necessary?
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.
The re-declaration is necessary because of how setpriority
is defined for glibc platforms:
pub fn setpriority(which: ::__priority_which_t, who: ::id_t,
prio: ::c_int) -> ::c_int;
Where __priority_which_t
is at the top of the file:
pub type __priority_which_t = ::c_uint;
Without this re-declaration, I get a type error when calling setpriority
on x86_64-unknown-linux-gnu
.
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.
Ah yep that'd do it!
src/bootstrap/config.toml.example
Outdated
@@ -152,6 +152,9 @@ | |||
# known-good version of OpenSSL, compile it, and link it to Cargo. | |||
#openssl-static = false | |||
|
|||
# Run the build with low priority | |||
#low_priority = false |
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.
In TOML configuration we tend to prefer dashes, could this perhaps be low-priority
?
src/bootstrap/config.toml.example
Outdated
@@ -152,6 +152,9 @@ | |||
# known-good version of OpenSSL, compile it, and link it to Cargo. | |||
#openssl-static = false | |||
|
|||
# Run the build with low priority |
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 you expand this to explain a bit about what this means? Referencing nice
here for Unix and "low priority" job object for Windows would probably be sufficient.
@bors: r+ |
📌 Commit 4f88106 has been approved by |
…hton Add an option to run rustbuild on low priority on Windows and Unix This is a resurrection of rust-lang#40776, combining their Windows setup with an additional setup on Unix to set the program group's *nice*ness to +10 (low-but-not-lowest priority, mirroring the priority in the Windows setup) when the `low_priority` option is on.
@bors r- This failed in the rollup:
|
Failed on macOS. I totally missed the condition that sends libc into the if #[cfg(any(target_os = "linux",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia"))] {
mod notbsd;
pub use self::notbsd::*;
} Gonna make this cfg even more awkward, sadly. (EDIT: For those curious, libc has a |
Looking back at this, it feels like it would be cleaner to patch libc to make |
Patching libc in this way would be backwards incompatible, though, right? I don't know libc all that well unfortunately (both the C library and the crate) so I can't really comment here. cc @rust-lang/libs, probably. |
Should be solvable with just |
...huh. I've never seen |
@bors r=alexchrichton |
📌 Commit dd0855d has been approved by |
⌛ Testing commit dd0855d with merge 3c94c57... |
💔 Test failed - status-appveyor |
⌛ Testing commit dd0855d with merge b011276... |
💔 Test failed - status-appveyor |
Another failure (hopefully spurious) to build rustc. @bors retry |
⌛ Testing commit dd0855d with merge e848729... |
💔 Test failed - status-appveyor |
Hmm, that's the second time it's failed with rustc just not compiling. I think I've seen this on another PR though so presumably not related? Very concerning though. I'll give it another chance. @bors retry
|
Add an option to run rustbuild on low priority on Windows and Unix This is a resurrection of #40776, combining their Windows setup with an additional setup on Unix to set the program group's *nice*ness to +10 (low-but-not-lowest priority, mirroring the priority in the Windows setup) when the `low_priority` option is on.
☀️ Test successful - status-appveyor, status-travis |
This is a resurrection of #40776, combining their Windows setup with an additional setup on Unix to set the program group's niceness to +10 (low-but-not-lowest priority, mirroring the priority in the Windows setup) when the
low_priority
option is on.