feat: Use channels to maintain job tokens & reuse the implicit token without dropping it first#878
Conversation
|
I am wondering if we could also attempt removal of the current |
If the help thread can be removed, then you can also replace that |
|
Eh, I've flirted with the idea of |
|
Eh, I've tried to get rid of helperthread, leading to a deadlock of a build on one of my test projects. I believe the issue here is similar to what you've ran into in #779 (comment) - we can't just acquire, as that might lead to the deadlock. By having a separate thread and a channel we can request a token like we do with |
I see why it doesn't work: Setting new values on However in the current PR it calls mpsc recv, which will succeed and stop blocking when the implicit token is released. (It's a shame there isn't built-in async executor in stdlib, otherwise this would be much, much easier.) |
|
Regarding the Since the spawning thread can consume all tokens (implicit and explicit), However this sounds so complex that I believe it should be a separate PR. |
|
Regading jobserver, I think that maybe it's a good idea to have a vendored implementation that never blocks.
|
NobodyXu
left a comment
There was a problem hiding this comment.
LGTM, but you would need a team member's approval to merge
|
I'll take a look later. I suspect it's mostly fine with @NobodyXu's approval. |
|
Thank you @osiewicz ! P.S. I was just granted the permission to approve and merge PRs in this repository. |
|
Thanks! |
|
I just discovered a problem with this PR: The mpsc in the jobserver will never be dropped so the token will never be put back to jobserver. I'm already working on a new PR which dramatically improves the parallel compilation and it will be in ready in a few days. |
|
Uh oh, that's no good. That's just off the top of my head though and I'm writing that reply at 3AM, so you know, I am probably wrong in some of my assumptions. :x |
No
But for tokens which are still in the mpsc, they will never be returned to the jobserver. |
|
I've opened #889 which fixes this and completely removes usage of thread, please have a look/review if you have time. |
This resolves a minor issue where build scripts could've acquired more job server tokens from Cargo than allowed by `-j` parameter. I've filled a PR at rust-lang/cc-rs#878 and we've iterated on the design over there since. TL;DR: some build scripts may complete a tad bit quicker, potentially shaving off a few seconds off of debug/release builds.
This resolves a minor issue where build scripts could've acquired more job server tokens from Cargo than allowed by `-j` parameter. I've filled a PR at rust-lang/cc-rs#878 and we've iterated on the design over there since. TL;DR: some build scripts may complete a tad bit quicker, potentially shaving off a few seconds off of debug/release builds. Full description of the issue is available in rust-lang/cc-rs#858 Release Notes: - N/A
This is a follow-up to #779 and addressing #858. This approach uses an additional thread for polling the jobserver.
Per my local tests, it fixes #858