-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Consolidate together Bevy's TaskPools #20699
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
Draft
james7132
wants to merge
74
commits into
bevyengine:main
Choose a base branch
from
james7132:prioritized-tasks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
This reverts commit 8f1eaa7.
The generated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Tasks
Tools for parallel and async work
C-Performance
A change motivated by improving speed, memory usage or compile times
D-Complex
Quite challenging from either a design or technical perspective. Ask for help!
D-Unsafe
Touches with unsafe code in some way
M-Needs-Migration-Guide
A breaking change to Bevy's public API that needs to be noted in a migration guide
M-Needs-Release-Note
Work that should be called out in the blog due to impact
S-Blocked
This cannot move forward until something else changes
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.
Objective
Fixes #1907. Spiritual successor to #4740, #12090, and #18163. Third time's the charm!
Bevy currently creates a 50%/25%/25% split between the Compute, AsyncCompute, and IO task pools, meaning that any given operation can only be scheduled onto that subset of threads. This is suboptimal in the cases where apps are not using any IO or Async Compute, or vice versa, where available parallelism would be under utilized due to the split not reflecting the actual use case. This PR aims to fix that under utilization.
Solution
This is based on #20649 and #20331. Unlike #12090 and #18163, this does not introduce any blocking thread pool (albiet those do still exist since we use
async-fs
/unblock
inbevy_assets
), and, in fact, does not make a major departure from the current status quo:RunNow
- When woken, these tasks are scheduled to immediately run after the currently running task yields.Compute
- Replaces theComputeTaskPool
's purpose.AsyncIO
- New. Dedicated to IO tasks that yield regularly with fairly low amounts of compute when woken. Ideal for network IO.BlockingCompute
- Replaces theAsyncTaskPool
's purpose.BlockingIO
- Replaces theIoTaskPool
's purpose.Compute
. This allows any task to freely use any thread in the task pool when scheduled, and prevents the lower priority groups from starving out higher priority tasks.This isn't strictly reliant on #20649, but it does make it easier to implement. The diff with that PR can be seen here.
This PR will remain in draft until #20649 or some equivalent is merged.
Testing
Right now, just bsaic example testing.
Future Work
Co-Authored By: Mike Hsu [email protected]