-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Bevy version
0.8-dev main aced6af
Operating system & version
macOS 12.3.1
What you did
Used minimal example:
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.add_system(sleep_system)
.run();
}
fn sleep_system() {
std::thread::sleep(std::time::Duration::from_millis(15));
}
and measured CPU usage with top
/ Activity Monitor.
The app was started using cargo run --release
.
What you expected to happen
Running with close to 0% CPU usage.
What actually happened
CPU usage of 10-15%
Additional information
Using SingleThreadedExecutor
by hardcoding it in bevy_ecs
pub fn parallel() -> Self {
// Self::new(Box::new(ParallelExecutor::default()))
Self::new(Box::new(SingleThreadedExecutor::default()))
}
results in a CPU usage of about 0.3%.
Similar behaviour exists for an empty window without using the renderer feature and also in the breakout example. For the empty window the CPU usage was quite low, whereas in the breakout example the CPU usage dropped about >10% with the change, but was still unexpectedly high.
I recorded flame graphs, to get the interactive version download the svg and open them in a browser.
ParallelExecutor
The call to std::thread::sleep
is at the highest "tower" on the left, you can zoom in when using a local interactive svg.
SingleThreadedExecutor
The same test without the sleep system results in 150% CPU usage with the ParallelExecutor
and close to 100% with the SingleThreadedExecutor
.
Issue #1462 is probably related but was closed and is less specific.