# The perf pass: 25 server rounds and 8 client rounds

> One night of measured speed-ups. The server started in 180 ms instead of 850 and stepped a world with one pilot in 0.005 ms, with every result bit for bit the same. The game's shadows stopped redrawing every frame, and the frame got 2.4 to 3.7 ms shorter.

Source: https://ringshadow.com/blog/perf-pass

18 October 2026 · Performance

On 18 October I set a standing goal: make the server and the game faster, one measured step at a time. Each round had the same shape: a baseline, a profiler trace, the biggest cost fixed, then before and after built side by side and run in turns on the same Mac, with the machine's load written next to every number. By the time I paused it that night, the server had had 25 rounds and the game 8.

![The bench's midnight scene: the Prospector at home facing the Citadel, the headlamp lighting the ground, two outlined units in front](https://ringshadow.com/blog/media/perf-pass/cover.jpg)

*One of the four scenes every client round was measured on: home at midnight, lamps and headlamp on.*

## The server: same results, less time

The rule for the server was that nothing it does may change. The wire's bytes, the save and the simulation's state hashes printed by the benches had to match before and after each round, and they did. Only one round changed behaviour: round 3 found three places in the Brood's nest code that read freed or dead memory, and fixed them.

| What | Before | After round 25 |
|---|---|---|
| The server's start, cold | ~850 ms, 5.5 s CPU | ~180 ms, 1.2 s CPU |
| The first step after a pilot joins | 12-25 ms | under 1 ms |
| The world's step, one pilot | 0.030 ms | 0.005 ms |
| A pilot's sight by day | 63 µs | 1.5 µs |
| Building and writing a pilot's snapshot | 3 + 44-70 µs | 1.9 + 5.3 µs |
| 16 pilots in one region, a tick | 230 µs | 73-75 µs |
| The idle call, nobody on line | 0.073-0.120 ms | 0.007-0.009 ms |

Most of the wins were about not doing the same work twice. The walking grids are built from the region's outline in runs instead of cell by cell. The fog of war is written eight cells to a word on the wire. A side's fog is shared between its pilots' snapshots, daylight over a region is stamped once, and the save's statements are prepared once.

These are the numbers of that night. Two days later the regions grew to 5.76 times their area, and the server's start went back up to 3.4 seconds of wall time, with that day's own load fixes. That's in [the bigger regions post](https://ringshadow.com/blog/bigger-regions).

Some things were tried and left out because they didn't help. Stepping regions on several threads works and is tested clean under ThreadSanitizer, but in today's world no two regions are busy enough at once to pay for waking a thread, so it ships switched off. The whole server suite also ran under AddressSanitizer and UBSan: clean.

## The game: the shadows held still

The game is GPU-bound in every scene, so that's where the time went. The biggest cost was shadows. The engine keeps a light's shadow pages from frame to frame only while the light holds still, and the sun and the ringlight turned a tiny bit every frame with the world's clock. Every shadow page was redrawn every frame. Now a shadow-casting light turns only in small steps, small enough that the tip of a 20-metre mast's shadow moves at most 10 cm. The sky's own sun keeps moving smoothly.

At home at noon the GPU frame went from 13.2 ms to 10.8, and at midnight from 15.3 to 11.6. The frame on which a step lands costs 0.6 to 2.4 ms more, once.

Other rounds: the engine was working out each instanced mesh's material descriptor again every update, and keeping it cut the game thread's slow frames by 10 to 18%. Two memory pools were sized to what the game uses, which saved the packaged game 124 to 387 MB. In 60 seconds of steady play per scene, at most 2 frames went over 33 ms. The packaged game is seated 2.3 to 3.2 seconds after it starts.

## The bench's scenes

- ![Home at noon, facing the Citadel](https://ringshadow.com/blog/media/perf-pass/01-home-noon.webp) Home at noon.
- ![Home at midnight, the headlamp on](https://ringshadow.com/blog/media/perf-pass/02-home-night.webp) Home at midnight.
- ![Slag Pockets at noon near the Matriarch's nest, its glowing hex floor](https://ringshadow.com/blog/media/perf-pass/03-nest-noon.webp) Slag Pockets, 55 cells from the nest.
- ![Cold Fork at noon, wave 10 coming down The Fork](https://ringshadow.com/blog/media/perf-pass/04-fork-wave.webp) Cold Fork, wave 10 down The Fork.
- ![Home at noon at the medium settings with rendering capped at 540 lines](https://ringshadow.com/blog/media/perf-pass/05-medium-540.webp) A candidate for slower Macs: medium settings, capped at 540 lines.
- ![The same with the engine's bounce light off: darker and flatter](https://ringshadow.com/blog/media/perf-pass/06-lumen-off.webp) The same with bounce light off: darker and flatter.

## Slower Macs

Every number above is from an M4 Max with 40 GPU cores, and a base M-series chip has a fifth to a seventh of that. Round 8 built the mechanism for quality tiers: the game reads the GPU's generation and core count, scores it, and picks top, high, mid or floor. Today it only picks and logs the tier, and every Mac draws exactly as before. The sets for each tier were measured but not settled, and the pictures of the candidates are above.

Coming: the settings for each tier, measured at each tier's screen size, and a decision on the lowest tier: keep the bounce light at 30 fps, or turn it off for 60. Nothing has been measured on a real low-end Mac yet.
