Skip to content
Devlog

Devlog #29 • Under the Hood: A Week of Making YUMA Faster

A technical devlog with charts: a server that holds 64 moving players, a world that builds a quarter faster, erosion in AVX2, why building six tiles at once was slower than one, and fewer hitches on your machine.

11 November 20268 min read

No new swords this time. The last few days went into the parts of YUMA you never see: the servers, the world generator and the frame time on your machine. This devlog is more technical than usual, and it has charts. Everything in it is on the development branch and comes with the next version.

9×shorter server frame with 64 moving players
6.4×faster erosion step on one core
−23%time to build a fresh world
0voxels of terrain changed by any of it

Every chart below shows a measurement before and after a change. Each row is scaled to its own “before”, so the gold bar is what is left of it.


A Server That Holds 64 Vikings

We started with a load test: a dedicated server without real clients, with bots that walk 150 m circles around homes spread across the map and ask for terrain the way real players do. With 64 of them the server fell apart within eight minutes. The frame time climbed from 17 ms to 160 ms and the memory kept growing.

The cause was housekeeping. Every moving player opens and closes patches of vegetation around them. Once a frame had used its time budget, the queue that throws old patches away handled one per frame, while 64 players opened about thirty. In six minutes the server registered 118,000 patches and destroyed 3,700. The dead ones stayed registered with their collision bodies, and every new registration got slower. Both queues now always work off a fixed share of their length, however long they are.

Dedicated server, 64 moving playersBeforeAfter
Server frame time8.9×
160 ms
17.9 ms
Memory−20%
8.6 GB, rising
6.9 GB, steady
Ryzen 9 5950X, server without a GPU, bots instead of clients. Frame time before: after eight minutes and still rising. After: the average of a steady run. A 60 Hz server frame is 16.7 ms.

The second find was a matter of order. The server builds terrain chunks by urgency. The chunk three metres under a player’s feet counted as one layer away, behind the whole ring of chunks around every other player. On a full server, a player walking just above a chunk border had no ground below them for the length of that walk, and the server holds a player in place until the ground is there. Now the layer below your feet is as urgent as the one you stand in.

Players held while they wait for groundBeforeAfter
Longest wait, 32 players163×
49 s
0.3 s
Longest wait, 64 players94×
75 s
0.8 s
Share of time held, 32 players24×
5.9%
0.25%
Share of time held, 64 players−62%
12%
4.6%
Same load test. Share of time: how much of all player time was spent held.

A World Builds a Quarter Faster

A YUMA world is computed from its seed: plates, climate, ice, rivers, erosion. Nothing is downloaded. On a fresh world this is the wait before you stand on your island, so we put a sampling profiler into our terrain lab and worked down its list.

  • The flood that fills basins and routes the water kept its open cells in a binary heap. Its keys never change, so a radix order with a bitmap gives the same cells in the same order without the heap.
  • The ice surface and the distances across flat land now use bucket queues.
  • The gradient noise remembers the last 256 lattice cells per thread. That alone halved the noise cost, from 91.6 to 45 CPU seconds.
Cold build of a world, up to the first islandBeforeAfter
All cores−23%
44.9 s
34.7 s
Four threads−22%
78.0 s
60.7 s
All cores, at the game's map resolution−22%
66.7 s
52.1 s
Terrain lab, Ryzen 9 5950X, seed 1337. The lab runs the same code as the game and the server.

The fine erosion runs later, on tiles of 337 × 337 cells around the players. Its three inner loops now handle eight cells per instruction on CPUs with AVX2. They do the same operations in the same order per cell and use no fused multiply-add, so the result is the same to the last bit. CPUs without AVX2 run the old code.

Erosion of one terrain tileBeforeAfter
One thread6.4×
11.8 s
1.83 s
All threads−44%
1.79 s
about 1.0 s
Terrain lab, 337 × 337 cells, Ryzen 9 5950X. Twenty tiles compare byte for byte against the old binary.

Six at Once Is Slower Than One

This one surprised us. The server built up to six erosion tiles at the same time, because a 16-core CPU has cores to spare. In the game a tile then took six seconds. The profiler said that time was not spent computing. A tile build sweeps 24.6 MB of working memory in every step, and builds running side by side fight over the cache and the memory bus.

So we measured it in isolation: 1, 2, 3, 6 and 12 tiles at once, each on its own thread.

Seconds per tile
1.28
2.15
2.93
6.33
11.2
tiles built at once
Tiles finished per second
0.78
0.93
1.02
0.95
1.07
tiles built at once

The server finishes about one tile per second, whatever the count. Building several at once gains nothing and makes every single tile arrive later, including the one a player is waiting for. The fix is one setting: one tile at a time on every machine, plus one extra slot for a tile right next to a player.

Four players join a world without any tilesBeforeAfter
One tile8.6×
6.0–6.5 s
0.65–0.80 s
21 tiles ready after−47%
31–33 s
15–19 s
Last player on the ground after−48%
39–42 s
16–26 s
Dedicated server, Ryzen 9 5950X, four bots 2 km apart, every tile cold. Bars are drawn at the middle of the measured range.

One Column, One Job

Terrain is stored in chunks of 32 m, stacked in columns. Most of what a chunk costs depends on where it stands and not on how high it is: the surface and its erosion detail. The server computed all of that again for every chunk of a column. Now the layers of a column that start together share one job and one set of column data.

Two smaller things came with it. Of the 16 erosion kernels per octave, 9 cannot reach the point they are asked about and only ever added zero, so they are skipped. And open air above the terrain is written in one go, without a visit to every voxel.

Terrain chunks on the CPUBeforeAfter
Column data: surface and erosion detail−37%
12.6 ms
7.9 ms
All voxels of a full-detail chunk−40%
28.0 ms
16.8 ms
Server with 4 players, per chunk−32%
22.5 ms
15.3 ms
First two rows: terrain lab, one thread. Third row: dedicated server on four cores, the average time a worker spends on one chunk.

The first version let the extra layers ride along for free. The measurement said no: 48% more chunks per second filled up the chunk limit and pushed the frame of a four-core server from 16.8 to 23–26 ms. Now a layer pays for its start like any other chunk, and it only rides along if nobody more urgent is waiting.

What this does not fix yet: with 16 or more players on the move, the start budget is used up all the time and the most urgent chunks all belong to different columns. Almost nothing rides along, and a chunk costs what it did before. That is next on the list.


Fewer Hitches on Your Machine

The client got its share as well.

  • Clouds on the Medium preset cost 10.5 ms less GPU time per frame on a Radeon 680M, which is integrated graphics. In a side-by-side comparison the picture differs by less than two identical frames differ from each other.
  • Trees further away than 40 m are drawn opaque, which saves 2.2 ms of GPU time on a forest walk with an Arc B580.
  • The Epic preset runs its global illumination one step lower, which saves another 2.1 ms there.
  • On Intel graphics the low latency mode is now off by default. It overslept into 40–50 ms hitches while walking.
Hitches and per-frame costs on the clientBeforeAfter
Vegetation spike when new terrain arrives10×
13 ms
1.3 ms
HUD update per frame15×
1.51 ms
0.10 ms
Frames longer than 50 ms on a test walk3.8×
15
2–6
Slowest 1% of frames on that walk−22%
50 ms
39 ms
The last two rows: a recorded walk through streaming terrain on an Intel Arc B580, same average frame rate before and after. Frames longer than 50 ms: 2 to 6 over the runs, drawn at 4.

Same World, Bit for Bit

A seed has to give the same world on every machine: client, server and lab. So none of the generator work was allowed to change a single voxel, and each step was compared against the old binary. 33 files per world cell match byte for byte, 20 erosion tiles match byte for byte, and the hashes of the packed voxels of 9,340 chunks are equal. All 62 test suites pass.

Your worlds stay exactly as they are. They just arrive sooner.

Skål!

Comments

  1. Loading comments...