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

Fix Build::compile_objects deadlock on parallel #829

Merged
merged 1 commit into from
Jul 20, 2023
Merged

Fix Build::compile_objects deadlock on parallel #829

merged 1 commit into from
Jul 20, 2023

Conversation

NobodyXu
Copy link
Collaborator

@NobodyXu NobodyXu commented Jul 20, 2023

jobserver::Client::acquire may block if there's not enough token.

To avoid blocking, this patch waits for child in a separate thread so that once the old compiler job is done, it may continue spawning new job instead of blocking forever.

This PR also makes sure that the released token is always re-acquired.

`jobserver::Client::acquire` may block if there's not enough token.

To avoid blocking, this patch waits for child in a separate thread so
that once the old compiler job is done, it may continue spawning new
job instead of blocking forever.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu
Copy link
Collaborator Author

P.S. This could be much easier if stdlib provides a simple async runtime.

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate, but seems necessary.

@NobodyXu
Copy link
Collaborator Author

NobodyXu commented Jul 20, 2023

Unfortunate, but seems necessary.

Thanks for the review, with this change it still spawns less threads than before, where two threads are spawned for every object.

@thomcc thomcc merged commit c83f5ee into rust-lang:main Jul 20, 2023
16 checks passed
@NobodyXu NobodyXu deleted the fix-compile-objects branch July 20, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants