-
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
Allow a negative number of jobs to count from maximum number of cores #9217
Comments
Testing my pull request for this made me uncover this issue: #9219. |
Not covered in my pull request:
|
Acceptance summary: this was discussed in the now-closed #9221
|
Wouldn't running it under |
cargo --jobs supports negative values: rust-lang/cargo#9217 currently this fails: ``` cargo nextest run --build-jobs -1 error: unexpected argument '-1' found tip: to pass '-1' as a value, use '-- -1' ``` because clap doesn't support this by default and requires `allow_hyphen_values = true` clap-rs/clap#1245
If you want your machine to remain usable during a compile session usually you want to set the number of jobs
lower than your maximum number of cores. But this varies heavily from machine to machine, and makes it
annoying to automate in bigger build scripts.
I would suggest extending the
--jobs
(or-j
) parameter to negative numbers, where-j -1
would be 'all but one core',-j -2
would be 'all but two cores', etc. This makes it really easy for scripts to maintain a usable machine and scaleto the number of cores available without having to look up the actual number of cores.
For sanity and convenience of automatic build scripts I would suggest that if
-j
was sufficiently negative to specify no or a negative amount of cores, to clamp the number of cores to at least 1, instead of giving an error.So to be precise I would suggest changing
jobs
toi32
instead ofu32
inBuildConfig::new
(and wherever necessary to make that work) and replace this line withI'm neutral on whether
0
should still not be allowed or whether that should be mapped to::num_cpus::get()
.The text was updated successfully, but these errors were encountered: