bevy: Very high CPU usage on MacOS
Summary
On MacOS, even simple Bevy apps cause very high CPU load; for example, even a blank app that just loads DefaultPlugins
to render a blank window sits at ~50% CPU usage on an Apple Silicon M1. Add a couple of rendered meshes and postprocessing and it’ll quickly go up to about ~90% CPU.
On Windows and Linux, the same app will comfortable sit below 1% (even with some light rendering.)
Additional notes:
- A MRP has been provided here.
- It uses the
opt-level = 3
etc. trick from the docs. - Compiling a
--release
build doesn’t make a difference. - In addition, when hiding the app, CPU load doubles, but I understand there have already been issues filed about this particular problem.
Bevy version
0.11.3
(but I also tried 66f72dd
, the newest commit on main
at the time.)
Relevant system information
- Rust 1.73.0
- MacOS Sonoma 14.0
AdapterInfo { name: "Apple M1", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M1", core_count: "8", memory: "16.0 GiB" }
What you did
- Build a “blank” Bevy app (code available here)
- Compile and run it
What went wrong
Expected behavior: the app should cause CPU load in the single-digit percentage range, like it does on Windows (<1% CPU, on a Ryzen 7.)
Actual behavior: the app caused ~50% CPU load.
About this issue
- Original URL
- State: open
- Created 8 months ago
- Reactions: 9
- Comments: 15 (10 by maintainers)
@alice-i-cecile - here’s a Google Drive link for the trace, I hope it works for you:
https://drive.google.com/file/d/1DxPcWasjVDRJDlL1_PSQh-5qhpxEeA3p/view?usp=sharing
That’s very helpful feedback.
This might be related to https://github.com/bevyengine/bevy/issues/9964.
Not sure how helpful this is, but I did try a couple of the more simple
wgpu
examples (from their latestmain
) and didn’t observe any noticeable performance issues that looked like the one I was seeing with Bevy.But please keep in mind that I’m new to this entire ecosystem (including Rust itself), so YMMV…
Trace downloaded and open locally, thank you very much!
Pulling this up in Perfetto, I’m still just seeing extremely long Prepare systems. I wonder if the way that wgpu polls is different on Mac? Perhaps it’s spinning a thread to try and vsync automatically?
Maybe a GDrive link? Feel free to delete it after a couple days.
@superdump it looks like we’re getting hit by excessively long prepare systems again 🤔
This is a long-standing bug, but it’s nice to see it seemingly isolated to Mac. Could we see a tracing log? https://github.com/bevyengine/bevy/blob/main/docs/profiling.md
I’d also like to try stripping out even more things from the
DefaultPlugins
, and see if we can reduce this to one or two offending plugins. Unfortunately I don’t have access to a Mac to test this myself, sorry.