You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CPU-bound tasks are spawned using spawn_blocking, which:
• Moves blocked tasks to other runtime threads, negatively impacting CPU affinity.
• Incurs additional costs due to task migration.
• Creates new threads for each spawn_blocking call until reaching the thread limit, potentially causing wait times and bring thread scheduler costs.
The main thread uses block_on for changing global state, which:
• Runs in a synchronous context, blocking the entire thread.
Proposed Solution:
This PR implements the following changes:
Utilizes Tokio’s multi-thread runtime as an asynchronous thread pool.
Executes all CPU-bound tasks in the main runtime thread instead of blocking threads.
Key Improvements:
• CPU-bound tasks run in the main runtime thread, effectively using it as an asynchronous thread pool.
• The main thread operates in an asynchronous context, eliminating the need for block_on calls.
Future Steps:
We still have numerous blocking calls that significantly impact performance. The next phase involves migrating all blocking calls to async/await calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teamThe issue/pr is created by the member of Rspack.
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Current Implementation Issues:
• Moves blocked tasks to other runtime threads, negatively impacting CPU affinity.
• Incurs additional costs due to task migration.
• Creates new threads for each spawn_blocking call until reaching the thread limit, potentially causing wait times and bring thread scheduler costs.
• Runs in a synchronous context, blocking the entire thread.
Proposed Solution:
This PR implements the following changes:
Key Improvements:
• CPU-bound tasks run in the main runtime thread, effectively using it as an asynchronous thread pool.
• The main thread operates in an asynchronous context, eliminating the need for block_on calls.
Future Steps:
We still have numerous blocking calls that significantly impact performance. The next phase involves migrating all blocking calls to async/await calls.
Checklist