Skip to content

Commit

Permalink
Run the multi-threaded executor at the end of each system task. (#11906)
Browse files Browse the repository at this point in the history
# Objective

The multi-threaded executor currently runs in a dedicated task on a
single thread. When a system finishes running, it needs to notify that
task and wait for the thread to be available and running before the
executor can process the completion.

See #8304

## Solution

Run the multi-threaded executor at the end of each system task. This
allows it to run immediately instead of needing to wait for the main
thread to wake up. Move the mutable executor state into a separate
struct and wrap it in a mutex so it can be shared among the worker
threads.

While this should be faster in theory, I don't actually know how to
measure the performance impact myself.

---------

Co-authored-by: James Liu <[email protected]>
Co-authored-by: Mike <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent 3a1b9b9 commit c4caebb
Show file tree
Hide file tree
Showing 2 changed files with 309 additions and 244 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
bevy_ecs_macros = { path = "macros", version = "0.14.0-dev" }

async-channel = "2.2.0"
concurrent-queue = "2.4.0"
fixedbitset = "0.4.2"
rustc-hash = "1.1"
downcast-rs = "1.2"
Expand Down
Loading

0 comments on commit c4caebb

Please sign in to comment.