Skip to content

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
@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