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

cargo doesn't respect the maximum number of jobs #7772

Closed
glandium opened this issue Jan 7, 2020 · 7 comments
Closed

cargo doesn't respect the maximum number of jobs #7772

glandium opened this issue Jan 7, 2020 · 7 comments
Labels
C-bug Category: bug

Comments

@glandium
Copy link
Contributor

glandium commented Jan 7, 2020

Problem
When running cargo with an explicit -jn, or via GNU make with an explicit -jn, the number of jobs can actually exceed the limit given. Presumably, the same happens without -jn, but now that I have 32 cores/64 threads, I can't find a crate that saturates them.

Steps

  1. clone the cargo repository
  2. run cargo build -j4 -Z timings
  3. open cargo-timings.html

You'll notice that at some point the number of active jobs goes over 4. This report (cargo-timing.zip) goes up to 7.

Notes

Output of cargo version:

cargo 1.42.0-nightly (86134e766 2019-12-23)
@glandium glandium added the C-bug Category: bug label Jan 7, 2020
@alexcrichton
Copy link
Member

This is a known bug with the cc crate where it releases its implicit process token which can be acquired by something else to spawn more jobs, but I don't think this is an issue with Cargo so I'm going to close this.

@glandium
Copy link
Contributor Author

glandium commented Jan 8, 2020

This is a known bug with the cc crate

Do you have a link to an open issue?

@alexcrichton
Copy link
Member

There is not currently an open issue on the cc crate.

@glandium
Copy link
Contributor Author

glandium commented Jan 9, 2020

Should this one be redirected there, then, with more details about the "known bug"? Because it's not clear to me how cc releases its process token, and why that ends up bumping the number of active jobs in cargo.

@alexcrichton
Copy link
Member

Er well I'm pointing out that this issue you're reporting has nothing to do with Cargo itself, so this isn't the proper place for this issue. This is likely very related to the behavior of the cc crate, rather.

I don't really consider the behavior a bug on the cc crate myself so there's not an issue for it, so calling this a "known bug" was probably not a great usage of words on my part.

@glandium
Copy link
Contributor Author

glandium commented Jan 9, 2020

I still don't understand how cc messes with the number of active job...

@ehuss
Copy link
Contributor

ehuss commented Jan 9, 2020

@glandium There is more detail at #7689 (comment) and #7344 (comment). The jobserver protocol is a very simple queue of tokens, and there is no protection that a client pushes extra tokens into the queue. The cc crate is releasing its implicit token to simplify its implementation. This will result in extra jobs, but they are not consuming CPU time since they are just waiting to reacquire their implicit token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants