-
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
Added support for negative --jobs parameter, counting backwards from max CPUs. #9221
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! This seems like a neat little feature which doesn't really have a ton of impact on Cargo itself in terms of overall design. One thing I'm curious about, though, is if you're aware of any precedent for this? We try to mirror the |
I know ninja defined |
Ah ok thanks for the clarification. Again this seems like a nice feature, but I'm a bit wary blazing the trail here when very established other build systems haven't implemented something like this. We discussed this at the Cargo meeting yesterday and one worry was that |
@alexcrichton I envision both being used, honestly. I don't know which would be more frequent. I am honestly not that familiar with
Yeah I would prefer it if there was at least a mention of it in the help.
I tried but couldn't think of a good short unambiguous description that fits in ~70 cols (the longest line in the options currently). Either way, even if someone assumed that |
let jobs = jobs.or(cfg.jobs).unwrap_or(::num_cpus::get() as u32); | ||
let jobs = match jobs.or(cfg.jobs) { | ||
None => ::num_cpus::get() as u32, | ||
Some(j) if j < 0 => (::num_cpus::get() as i32 + j).max(1) 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.
I think I'd personally prefer that this return an error if the result is less than one rather than clamping to one
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.
@alexcrichton I think it's better if not, suppose that a build script contains -j -2
but is then run on a dual-core machine, now your build breaks. Also, -j 1000
doesn't give an error either.
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.
Hm this is something I'm worried about though in that it's sort of hidden behavior. Using -j100
when you have 2 cpus just means "spawn up to 100 things at the same time" which is always possible, you're basically asking the kernel to do tons of scheduling for you. If the request ends up being "spawn at most -N" tasks I'm not sure Cargo can reasonbly handle that and I would prefer we be conservative and return an error.
If in the future, though, the script case is common enough and the error is just getting in everyone's way we could change it to clamp to 1
Ok this seems reasonable enough to me to go ahead and merge. We'll be trailblazers here in that there's not really any precedent for this, but I don't think that's the end of the world. @rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@rfcbot concern docs This needs some documentation updates. Can you make the following updates?
|
@ehuss The config docs I have no problem with, I can do that. I did try to think of a way to specify the command line doc but I could not find a concise wording I was happy with. My concern is that the command line docs are generally very terse and the best description I could come up with was still significantly longer than all others. So suggestions are definitely welcome. |
I wouldn't worry too much about the clap CLI help string. Maybe something like |
☔ The latest upstream changes (presumably #9367) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping @orlp, are you still interested in moving forward with this? I think the documentation was the only thing that needed updating. |
How feasible would it be to accept a very basic expression grammar for |
I'm going to close due to inactivity. We are still interested in some solution here. Feel free to reopen if you have a chance to work on it again. |
Closes #9217.
Closes #9219.