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

runtime: move the task out of the lifo_slot in block_in_place #6596

Merged

Conversation

wathenjiang
Copy link
Contributor

@wathenjiang wathenjiang commented May 29, 2024

If we heavily call the spawn_blocking, there might be no available thread to run the current core. Except the task in the lifo_slot, all tasks in cores can be stolen, so we move the task from the lifo_slot to the run_queue before calling the spawn_blocking in the block_in_place.

This can prevent the starvation of the task in lifo_slot in edge cases.

@github-actions github-actions bot added the R-loom-multi-thread Run loom multi-thread tests on this PR label May 29, 2024
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels May 29, 2024
@carllerche
Copy link
Member

This change makes sense to me, thanks.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thank you.

@Darksonn Darksonn merged commit 873cb8a into tokio-rs:master May 30, 2024
80 checks passed
@wathenjiang wathenjiang deleted the move-task-outof-lifo-slot-before-block branch May 30, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime R-loom-multi-thread Run loom multi-thread tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants