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

Add an option to run rustbuild on low priority on Windows and Unix #42069

Merged
merged 3 commits into from
May 20, 2017

Conversation

QuietMisdreavus
Copy link
Member

@QuietMisdreavus QuietMisdreavus commented May 17, 2017

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.

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
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@porglezomp
Copy link
Contributor

nice

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 18, 2017
@aidanhs
Copy link
Member

aidanhs commented May 18, 2017

Thanks for the PR @QuietMisdreavus, we'll make sure @alexcrichton or another reviewer gets to this soon.

Copy link
Member

@alexcrichton alexcrichton left a 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!

//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;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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!

@@ -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
Copy link
Member

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?

@@ -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
Copy link
Member

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.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented May 18, 2017

📌 Commit 4f88106 has been approved by alexcrichton

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 18, 2017
…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.
@Mark-Simulacrum
Copy link
Member

@bors r-

This failed in the rollup:

[00:01:36] Command failed. Attempt 2/5:
[00:01:37]    Compiling bootstrap v0.0.0 (file:///Users/travis/build/rust-lang/rust/src/bootstrap)
[00:01:37] error[E0308]: mismatched types
[00:01:37]    --> src/bootstrap/lib.rs:128:31
[00:01:37]     |
[00:01:37] 128 |             libc::setpriority(PRIO_PGRP, 0, 10);
[00:01:37]     |                               ^^^^^^^^^ expected i32, found u32
[00:01:37] 
[00:01:39] error: aborting due to previous error
[00:01:39] 
[00:01:39] error: Could not compile `bootstrap`.
[00:01:39] 
[00:01:39] To learn more, run the command again with --verbose.
[00:01:39] Build completed unsuccessfully in 0:00:02
[00:01:39] make: *** [prepare] Error 101

@QuietMisdreavus
Copy link
Member Author

QuietMisdreavus commented May 19, 2017

Failed on macOS. I totally missed the condition that sends libc into the notbsd module in the first place:

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 cfg_if! macro that lets it set up chains like this.)

@QuietMisdreavus
Copy link
Member Author

Looking back at this, it feels like it would be cleaner to patch libc to make PRIO_PGRP be of type __priority_which_t on platforms where the signature of setpriority requires that. Otherwise, this would just require updating this cfg dance any time libc adds more Unix platforms. This is especially important because the cfg set I looked at to make this PR (that on master) is different than the cfg set that was actually pulled in by my rustc build. I would effectively break bootstrap for those platforms that get left out of the cfg condition but don't have tests in CI.

@Mark-Simulacrum
Copy link
Member

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.

@sfackler
Copy link
Member

Should be solvable with just PRIO_GRP as _.

@QuietMisdreavus
Copy link
Member Author

...huh. I've never seen some_value as _ before. Works like a charm on my own Linux system!

@Mark-Simulacrum
Copy link
Member

@bors r=alexchrichton

@bors
Copy link
Contributor

bors commented May 19, 2017

📌 Commit dd0855d has been approved by alexchrichton

@bors
Copy link
Contributor

bors commented May 19, 2017

⌛ Testing commit dd0855d with merge 3c94c57...

@bors
Copy link
Contributor

bors commented May 19, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 20, 2017
@bors
Copy link
Contributor

bors commented May 20, 2017

⌛ Testing commit dd0855d with merge b011276...

@bors
Copy link
Contributor

bors commented May 20, 2017

💔 Test failed - status-appveyor

@Mark-Simulacrum
Copy link
Member

Another failure (hopefully spurious) to build rustc.

@bors retry

@bors
Copy link
Contributor

bors commented May 20, 2017

⌛ Testing commit dd0855d with merge e848729...

@bors
Copy link
Contributor

bors commented May 20, 2017

💔 Test failed - status-appveyor

@Mark-Simulacrum
Copy link
Member

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

[00:57:55]    Compiling rustc v0.0.0 (file:///C:/projects/rust/src/librustc)
[01:01:56] error: Could not compile `rustc`.
[01:01:56]
[01:01:56] To learn more, run the command again with --verbose.
[01:01:56]
[01:01:56]
[01:01:56] command did not execute successfully: "C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage0/bin\\cargo.exe" "build" "-j" "2" "--target" "x86_64-pc-windows-msvc" "--release" "--locked" "--features" "" "--manifest-path" "C:\\projects\\rust\\src/rustc/Cargo.toml"
[01:01:56] expected success, got: exit code: 101
[01:01:56]
[01:01:56]
[01:01:56] Build completed unsuccessfully in 0:40:28

@bors
Copy link
Contributor

bors commented May 20, 2017

⌛ Testing commit dd0855d with merge 01951a6...

bors added a commit that referenced this pull request May 20, 2017
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.
@bors
Copy link
Contributor

bors commented May 20, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexchrichton
Pushing 01951a6 to master...

@bors bors merged commit dd0855d into rust-lang:master May 20, 2017
@QuietMisdreavus QuietMisdreavus deleted the low_pri branch August 16, 2017 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants