The graphics card was waiting for us
In November the game was limited by the CPU on my PC: the graphics card finished a frame in 2-4 ms and then waited. How we measured where the CPU time went in a Bevy app, and the fixes that paid: shared materials, a single-threaded Update, the swapchain wait moved off the task pool, and a sky light refiltered four times a second.

On my PC the graphics card finished a frame in 2-4 ms and then waited for the CPU. In November we measured where the CPU time went and cut what was ours.
The biggest wins were a hundred copies of one material, six hundred tiny systems spread over threads at a cost larger than their work, and a swapchain wait that held up the physics.
On my PC, which in November played on Native-like at 144 Hz, the graphics card finished its work in 2 to 4 ms and the frame took 9 to 12, against the 6.9 ms that 144 Hz allows. The card was idle for the rest of it, waiting for the CPU. Between 2 and 20 November we spent seven merges on CPU time.
Measuring on a machine that lies
The test machine has a datacenter GPU from 2016, our minimum-spec target, and runs the test level at 16 to 30 fps: its frame rate says nothing about the CPU. It is also a virtual machine that shares its host with the build machine, so a build inflates every wall-clock time. The same scene measured 9.1 and 15.4 ms on one morning.
So the bench changed what it counts. It reads the CPU time the kernel charged to each thread from /proc/self/task/*/stat, which only counts while the thread really runs. The unit is the kernel tick, 10 ms, too coarse for one frame, so the bench adds the ticks over a whole capture and divides by the number of frames. Next to it, it times the render world without the wait for the swapchain image, and the main world with exactly one fixed tick: at 20 fps our 64 Hz fixed schedule runs three or four ticks per frame, which a fast PC never does. Before and after runs alternate, three per position, and we keep the medians. The longer of the two threads is our estimate of what a CPU-bound machine pays. A census counts entities, meshes, shadow casters and distinct materials per mesh name, and a switch despawns one kind of entity halfway through the warm-up, so we can price it by removing it.
For the per-system view we use Tracy. Bevy already wraps every system in a span with its real name, when the trace feature is on.
Under the hood: Tracy on Bevy, inside a virtual machine
Features. bevy/trace_tracy turns on the Tracy layer and the GPU context, and it also enables trace, the feature that puts a span around every system. (bevy_internal/trace_tracy on its own does not.) We list both anyway, so the profile still works if that ever changes.
No invariant TSC. In the virtual machine Tracy refused to start without an invariant timestamp counter. The timer-fallback feature of tracy-client-sys, a dependency we declare only to switch that feature on, makes it use the system clock, with a measured resolution of 16 ns.
A hundred copies of one material
On 2 November, removing just the procedural rocks and grass clumps took about 2 ms off the render world, far too much for what they are. Every grass clump built its own material at spawn, and the edge dressing alone lays about a hundred clumps with identical settings. For Bevy’s renderer that is a hundred bind groups where one would do, and draws that cannot be batched. Ruined walls, their dark cores and the moss shells did the same on a smaller scale.
The spawners have several callers, editor included, so we left them alone: a system in PostUpdate points every new mesh with one of the listed names at the first material with the same look, and the copy is freed with its last handle. Nobody edits those materials per object, so sharing cannot leak a change from one clump to its twins. Distinct materials went from 331 to 225.
On the test machine, at 1920×1009, over three camera positions with three runs each (medians), the render world went from 8.22 to 6.35 ms and the main world from 6.55 to 6.28 ms. The slower of the two threads, taken run by run, went from 8.63 to 6.92 ms. After that the two cost about the same, 6.28 and 6.35 ms, so either could be the slower one and the main world was next.
Under the hood: what "the same look" means
The key. The material’s Debug output with the live fields blanked. The weather writes the wind on every foliage material alike, so a clump spawned after a gust would otherwise never match its twins:
fn look_key(&self) -> String {
let mut still = self.clone();
still.extension.wind = Vec4::ZERO;
format!("{still:?}")
}
A string key is slow by hashing standards, but the query is Added<MeshMaterial3d<M>>, so it only runs on the frame a mesh appears.
Six hundred systems that do almost nothing
On the test machine Tracy showed Update taking 2.78 ms per frame, of which only 1.20 ms was inside systems. There were 606 system starts per frame, and 449 of those systems returned in under 4 µs. The other 1.58 ms, about 2.6 µs per system, was mostly the multi-threaded executor’s overhead: a task for each system and a worker woken to run it, which on a virtual machine is not cheap.
We put Update on Bevy’s single-threaded executor:
app.edit_schedule(Update, |schedule| {
schedule.set_executor(SingleThreadedExecutor::new());
});
The work worth spreading out (par_iter over the scene, physics, the render world) keeps the thread pool. A first try that also put the render world in line was worse. With PostUpdate and FixedUpdate single-threaded as well, the main world measured 7.75 ms against 5.47 with Update alone.
The same merge removed two kinds of waste. Of 446 transforms changed per frame, about 150 were temple stones standing still: sleeping dynamic bodies whose physics interpolation rewrote the same Transform every frame, which then propagated and was uploaded again. A sleeping body now gets avian’s NoTranslationEasing, NoRotationEasing and NoScaleEasing markers until it wakes. The 802 stream cobbles became one mesh per 4 m cell.
Main world, on the test machine, median of three positions, in a separate series later that day, with the host busier than in the morning: 7.33 ms before, 6.49 ms with the cobbles, the sleeping stones and one smaller fix, 5.47 ms with the single-threaded Update too. Two identical runs could differ by 1.5 ms that day, so the first step is a direction, not a measurement; the single-threaded Update won in every position.
The swapchain wait that held up the physics
The averages hid stalls: about every second or two a fixed tick took 33 to 43 ms, and the whole main-world update up to 72 ms, in frames that needed 5 ms of CPU.
prepare_windows is the render system that acquires the next swapchain image. In Bevy it is an ordinary system, so the executor hands it to a thread of the compute task pool, where it blocks until the GPU or the monitor gives an image back. That pool is shared with the main world. A main-world system waiting for its own par_iter tasks runs other pool tasks while it waits, and sometimes the one it picked up was prepare_windows. On a GPU-bound machine the whole game update then waited for the swapchain.
The fix is an exclusive system on the render thread, which no pool thread can take. It runs prepare_windows itself, just before the stock one, which then finds the image already acquired. It skips frames where the window changed size or present mode: there the stock system must create the new swapchain, and acquiring twice is an error.
Under the hood: the swapchain acquire on the render thread
// registered in the Render schedule
acquire_swapchain_on_render_thread
.in_set(RenderSystems::PrepareViews)
.after(create_surfaces)
.before(prepare_windows)
fn acquire_swapchain_on_render_thread(world: &mut World) {
let reconfiguring = world.get_resource::<ExtractedWindows>()
.is_none_or(|w| w.windows.values()
.any(|w| w.size_changed || w.present_mode_changed));
if !reconfiguring {
let _ = world.run_system_cached(prepare_windows);
}
}
With the same build and camera, the 99th percentile went from 60.3 to 9.5 ms, and frames over 25 ms from twelve in twenty seconds to none. The average fixed tick dropped from 1.47 to 0.99 ms, mostly because the stalled ticks were gone.
Six seconds standing still after 100%
On the test machine the loading bar reached 100% and then the game stood still for almost six seconds. The water solver was running, twice, about 1.85 seconds each time, followed by the rocks, the stream cobbles, the tree bodies and the grass maps. All of them had been gated to run in the editor or in play, never during loading, so they all started on the first frame of play.
The fix went in the same merge as the swapchain one, on 7 November: those systems now also run during loading, and loading ends only when the world is quiet (no long update, no pipeline compiling), with a 15 s ceiling. The second water solve came from an editor resource that read the terrain settling as a user gesture; it is gone. Loading now ends at 11.4 s instead of 11.9, and no update in play goes over 25 ms.
The sky light, refiltered every frame
On 9 November the render thread took 8.76 ms at one position, 7.40 of them preparing resources and running the render graph. The heaviest single system there was prepare_generated_environment_map_bind_groups, at 0.8 to 1.7 ms. Bevy’s atmosphere renders the sky into a cubemap and filters it into the diffuse and specular maps that light every material. It does both every frame, and the preparation rebuilds about thirty texture views, a uniform buffer and every bind group of the mip chain from scratch. Our sky changes over seconds.
Between refreshes we now take the component that drives the filter off the probe entity, right before bind groups are prepared. The filtered maps are persistent, so materials keep reading the last filtered sky.
The first version refreshed every 50 ms: one frame in seven at 144 fps, but every second frame at the test machine’s 21 to 28 fps (a frame there lasts 36 to 48 ms). Since 20 November it is every 250 ms in play and every 50 ms in the editor, where the hour and the fog are dragged by hand. It also drops back to 50 ms when the directional lights’ total illuminance changes by more than 2% since the last refresh: a lightning flash is a 25,000 lux directional light, and 250 ms could hold it for a quarter of a second or miss it. On the test machine’s render thread, against the 50 ms version, the cost went from 0.79 to 0.24-0.33 ms per frame at the pond on Medium, and from 1.12 to 0.35 ms in the meadow on Native-like.
Under the hood: skipping a Bevy render system without forking it
The cut. An exclusive render-world system, ordered after RenderSystems::PrepareResourcesFlush and before RenderSystems::PrepareBindGroups, removes RenderEnvironmentMap from the probes on frames that do not refresh. Extraction puts it back the next frame. A probe that has never been filtered is never skipped, or it would light the scene with black placeholder maps until the next refresh.
Why the cut sits there. It comes after PrepareResources on purpose. The filter’s intermediate texture is still requested from Bevy’s TextureCache every frame, so the cache keeps it. Cut earlier, the texture would go unused for a few frames, the cache would drop it, and every refresh would allocate 8 MB again.
What did not pay
A ceiling on the sun’s shadow cascades per profile, and 328 shore plant clumps merged into 29 patches, cut the shadow casters from 1,281 to 982 without a measurable change on the render thread: shadows cost about 1.2 ms per frame there, nearly all of it fixed per pass. Bevy 0.19’s occlusion culling made the GPU slower and saved no CPU, so it stays off.
Rendering the water’s reflection every other frame pulsed visibly at 30 fps, so it now skips frames only above 100 fps.
On 17 November the render thread was still the slower one on the test machine, 9 to 10 ms at other positions against 7.7 for the main world; about 5 ms of it is Bevy encoding and submitting passes, and none of our own systems averages above 0.3 ms.
What is missing: a proper before-and-after on my PC. From the test machine’s numbers we expected the material change alone to take about 100 fps to 125-130 in the same scenes. In mid-November my frames still took 9 to 12 ms, so that estimate did not carry over to my CPU and operating system, and only a measurement on my PC will say why.