Late Game Performance

Same decisions, sooner.

A Timberborn 1.1 mod for big colonies that stutter. It removes work the game repeats over and over, so you get fewer lag spikes and shorter freezes.

  • Your beavers decide exactly what they would anyway. Each speed-up gives the game's own answer, checked against the game's code.
  • Built for BeaverBuddies co-op. Nothing that affects the simulation is a setting, so every player on the same version runs the same code.
  • For big colonies. Hundreds of beavers late in a game. A small colony has little repeated work to remove.

Played in late-game colonies of 350+ beavers, most recently as 0.4.30. This release hasn't been played yet. Needs Harmony and Mod Settings; try it on a copy of a save. What is tested, and what isn't

Measured in play, per request, in a 362-beaver colony. Verify every feature ran the game's own code beside the mod's and compared every answer. It is one part of a tick: the overall tick time did not measurably drop in that session.

Big colonies do the same work over and over.

Every hauler decision, finished road and lumberjack's search makes the game redo work whose answer mostly hasn't changed. In a small colony that costs nothing. With hundreds of beavers it adds up, and you feel it as stutter.

This mod keeps answers the game has already worked out, does heavy work on other CPU cores, and skips lookups that can't change the result. Beavers make the same choices, just sooner.

What it changes in your game

Six jobs the game repeats all the time, each done faster and the game's own way. Most can be checked against the game while you play.

The game's own tickSame order, same answers. The mod only shortens the work inside it.

Haulers stop redoing their homework

For every hauler looking for work, the game asks every building in the district for its jobs and sorts the list. The mod keeps each building's jobs until something changes, then sorts the list the game's way.

Work
Kept, reused until it changes
Checked
HaulCacheVerify

Road changes stall the game less

After a path, stair or platform is finished, the game rebuilds every building's route map on the main thread. The mod spreads that over up to 7 worker threads. The maps come out exactly as the game builds them.

Work
Other CPU cores
Checked
Node for node in tests

Lumberjacks search smarter

To find a tree, the game measures the path to every marked tree, though most are still growing. The mod leaves out the measurements that can't change the answer, and a lumberjack with no grown tree in reach stops at the first tree. Lumberjacks, gatherers and farmers get the game's own result.

Work
Skipped where it can't matter
Checked
YielderSearchVerify

Saves freeze the game for less

Trees, crops, paths, levees and platforms, nearly all of a big colony, are saved on worker threads. Beavers and workplaces stay on the main thread. The save file is the same.

Work
Other CPU cores
Checked
SaveSnapshotVerify

Fewer memory clean-up freezes

The game cleans up memory with everything stopped. In a big colony that can freeze it for most of a second, about once a minute. One tick-box spreads the same work over many frames.

Work
Spread over many frames
Choice
Yours, one box

One hitch stays one hitch

After a long frame, such as an autosave, the game crams what it missed into the next few frames. In a logged 354-beaver session, each hitch became about a second of stutter. The mod runs the same ticks, in the same order, over ordinary frames.

Work
Paced, not dropped
Checked
Same ticks, same order

And the rest of the crew

Entities with nothing to tick skipped
The game visits ten thousand trees, crops and paths every tick, though they have nothing to do. The mod ticks only the ones that do, in the game's own order.
Beavers off the roads kept
A beaver in a field choosing where to eat or rest makes the game search the terrain again for every building it considers. The mod keeps up to 32 searches and continues them instead. The distances are the game's.
Plant water, soil and the water map other cores
Plant water levels, changed soil cells and the water map copy are worked out on worker threads.
District counts and homes kept
Each district's resource count and the every-tick search for a beaver to move into a home stop redoing unchanged work.
"Can a beaver reach that?" leaner
After a road change the game floods the whole walkable colony to answer this. The mod floods it the same way, without first resetting every tile of the map.
Terrain route maps other cores
Built on worker threads alongside the road ones, with the game's contents.
Per-frame chores less often
The audio listener, the alert lists, the selection panel, far and off-screen animation, the physics sync and water rendering stop redoing work every frame. None of it touches the simulation.
Timing lines in the log yours to read
Ticks per second, where the main thread's time goes, the longest frame, memory clean-ups and saves, so you can measure your own colony.
[LateGamePerformance]Simulation features:
  1. HaulCache on
  2. RouteMaps on
  3. YielderSearch on
  4. TerrainMaps on
  5. PlantWater on
  6. DistrictCounts on
  7. WaterMapCopy on
  8. SoilScans on
  9. TerrainSearch on
  10. IdleEntities on
  11. HomeSearch on
  12. Reachability on
The startup line in Player.log. It reads the same on every computer running this version.

Built for BeaverBuddies co-op

In multiplayer every player's game must calculate exactly the same thing. A mod that changed even one answer would be worse than no mod. So keeping co-op games in step comes before every speed-up.

  • The game's own answers. Hauling lists, tree searches and route maps match the game's own. Tests compare them with the game's code.
  • Same version, same code. Nothing that affects the simulation is a setting, so two players can't drift apart by editing a settings file.
  • Never tied to one player's screen. Which route maps get built never depends on what a single player looked at.
  • Played in multiplayer on two computers, including a 35-minute session logged on both. Larger groups haven't been reported yet.

What may differ between players

Incremental garbage collection, thread counts, timing logs and the verify settings. They don't affect the simulation, so each player can choose them. Everything else needs the same mod version and the same game version, updated together.

What it always does

  • Can be checked against the game. The verify settings run the game's own code alongside and log any difference, without changing what the game is told.
  • Switches a feature off if it hits an error, and lets the game's own code run instead. A dialog then asks every co-op player to restart.
  • Leaves a feature off if a game update changed something it needs.
  • Stores nothing in your saves.

What it never does

  • Approximate. It skips work only when the answer cannot change.
  • Change what your beavers decide on purpose. The known difference is explained in the FAQ.
  • Touch a game file, unless you tick Incremental garbage collection.
  • Need anything besides Harmony and Mod Settings.

What the numbers say

Every figure says where it was measured and what it doesn't promise. Your gain depends on your colony and your computer. There is no controlled frame-rate benchmark yet.

Path lookups in one tree search

Test harness, not a live game: a model forest of 2,000 marked trees, 50 of them grown. Fewer is better.

Game's own 2,000 The game measures the path distance of every marked tree before asking whether it has anything to take.
With the mod 51 Only the lookups that can change the answer are made, in the game's order. The answer is the same.
View chart data as a table
Path lookups in one tree search
CaseLookups
Game's own search2,000
With the mod51

How much it saves in your colony depends on your forest: a lot when most marked trees are still growing, nothing when every marked tree is grown.

Time to rebuild 420 route maps

Test harness: a 22,600-tile road network, heavier than a real colony's. Less is better.

One at a time 1.8 s One after another on a single thread, as the game rebuilds them.
On 7 workers 0.23 s The same maps spread over 7 worker threads. The contents are identical.
View chart data as a table
Time to rebuild 420 route maps
CaseTime
One at a timeabout 1.8 s
On 7 workersabout 0.23 s

In the game the workers run alongside the tick. The main thread still builds a map itself if it needs one before a worker gets to it.

In play, against the game's own code

Played: a 362-beaver colony with Verify every feature on, so the game's code ran beside the mod's and every answer was compared.

Part of the tickGame's ownWith the modAnswers
Hauler job list, per request0.94 ms0.24 msSame · 0 differences
District resource counts0.68 ms0.56 msSame · 0 differences

Tree search, plant water, water map copy, soil scans, terrain search, home search and reachability also reported 0 differences in that session. The overall tick time did not measurably drop in a session that short.

The same colony, now and before

Played: the colony at 362 beavers, against a recording of it at 359 beavers made on an earlier build of this mod. So these show what the newer work added, not the whole gain over the unmodded game.

MeasureEarlier buildNowChange
Autosave freeze0.84–1.26 s325–430 msShorter
Entities saved on the main thread3,670411Fewer
Plant water, per tick0.31 ms0.03 msFaster
Animations, per frame1.64 ms0.87 msFaster
Beaver decisions, per tick9.3 ms8.6 msFaster

One session each, one computer. The overall tick time did not measurably drop in that session.

Memory clean-up freezes

Played: one 35-minute multiplayer session, same save and same mods, on two computers.

Without incremental collectionWith it
Freezes from memory clean-up39, median 675 ms each (about 30 s in total)1 frame over 50 ms outside saves
In playDrastic spikes at high tick ratesA much steadier frame rate

Two different computers, so hardware counts as well as the setting. Memory in use was 1.6 to 2.7 GB on both.

Checked against the game's code

Test harness, run against the installed game's own assemblies.

  • 543 checkspass, including 154 patch targets
  • 9.5 millionroute map nodes compared: every one identical
  • 4,000 forestsrandom, with 0 differences from the game's tree search
  • 1,200 searchesresumed terrain searches, all at the game's distance

What is tested, and what isn't

Tested extensively, but still a young mod, so here is the honest picture. Try it on a copy of a save first.

This release, 0.4.31, hasn't been played yet. Everything under In play is from earlier builds.

Tested

In play

  • A late-game save of about 350 beavers: noticeably fewer lag spikes, then "working well" and "working amazingly well".
  • A 362-beaver colony with Verify every feature on: every verify setting reported 0 differences from the game's own code, including the save snapshot at an autosave.
  • Multiplayer on two computers, including a 35-minute session logged on both.

Against the game's code

  • 543 automated checks pass against the installed game's own assemblies, including 154 patch targets.
  • Rebuilt route maps are identical to the game's, node for node.
  • The tree and plant search gives the game's answer in 4,000 random forests, and the lumberjack's early stop in 4,000 more.
  • The tick loop, saves, plant water, soil and the water map copy each match the game's own code.
  • Resumed terrain searches give the game's distance in every test.

Not yet

  • This release in play. 0.4.30 was played, but the logs of that session haven't been read yet.
  • The frames that get slower each evening. They are still unexplained.
  • A verify session longer than about twenty minutes of play.
  • A before-and-after of each feature in the same save. The improvement is reported from play and logs.
  • A controlled frame-rate benchmark.
  • A co-op game where one player has the verify settings on and another has them off.
  • Groups larger than two players.
  • The main-menu notice about incremental collection, because the test computers already have it on.

Five minutes to install

  1. Harmony and Mod Settings from the Steam Workshop.
  2. The ZIP under Assets on the release page, not Source code, into Documents\Timberborn\Mods.
  3. Playing co-op? Every player installs the same version, and you update together.