0.4.14
Late Game Performance for Timberborn 1.1.2.4. Played in-game and reported as working well. This release includes everything since the previous release, 0.4.9: 0.4.10 to 0.4.13 (see their release notes: one settings checkbox, faster tree search when lumberjack flags are full, plant water checks, terrain route maps and district counts on worker threads, background saves) and the new parts below.
Multiplayer: every player installs this same version. That is all. The two new parts that touch the simulation give the game's exact results and are not settings; the rendering part never touches the simulation.
In the test harness the water copy and the soil scans together take about 1.8 ms per tick off the main thread on a 256 x 256 map. How much that is in the game depends on the map and on Unity's runtime; the stats lines below will say.
New: the water map copy is made on a worker thread
Every tick the game copies the whole water map into the copy that other threads read (ThreadSafeWaterMap.Tick): 0.70 ms per tick in the measured colony. What that copy will hold is known as soon as the water simulation's last task has finished, and nothing changes the simulation's arrays after that until the next tick. So the mod makes the same copy right then, on that worker, into a second set of arrays (the flow directions with the game's own calculator), and in the next tick the main thread only swaps the two sets.
- Nothing reads the second set while it is being written: the parallel tasks read the set that was current when their tick started, and the main thread reads through the map's own fields, which only change in the swap.
- The game makes its own copy, as without the mod, on any tick where the arrays may have changed after the copy: a queued building, dam or terrain change was applied to the water layout, the simulation was reset, a water layer was added, the game flags a column change, or no copy was ready.
- Harness, 256 x 256 map with 3 water layers: the game 0.83 ms on the main thread; the mod 0.54 ms on a worker and under 0.001 ms on the main thread.
New: soil moisture and contamination scans skip tiles with nothing changed
Every tick the game walks every tile and every soil layer twice (moisture, contamination) to find the few cells that changed. The mod walks them in the same order but reads eight tiles' change flags at once and skips the group when none is set; for the rest it runs the game's loop and the game's own per-cell method. Same cells, same order, same values. Harness, 256 x 256, 3 layers, 1 cell in 500 changed: 0.59 ms → 0.10 ms per scan.
New: water rendering stops re-doing work that changes nothing on screen
Rendering only. WaterRendering = false in LateGamePerformance.cfg turns it off.
- The game switches every water tile off and the ones with water back on, every tick. The mod only switches tiles whose state changes.
- For flow directions and flow limits, the game re-uploads each tick data the graphics card already holds. The mod leaves that upload out only when it can show it is identical: same texture, same array, exactly one data swap since the card got it. Otherwise the game uploads as usual. Depths, contamination, columns and link barriers are left alone.
- Not done: skipping empty water layers. It would need whole layers compared, which costs about what the upload does.
New log lines
[LateGamePerformance] Simulation features: HaulCache on, RouteMaps on, YielderSearch on, TerrainMaps on, PlantWater on, DistrictCounts on, WaterMapCopy on, SoilScans on. These are the same for every player on this version.
[LateGamePerformance] Last 1000 ticks. WaterMapCopy: 996 ticks swapped in the copy made on a worker thread (0.540 ms there per tick); the game copied on the main thread in 3 ticks where the water layout changed and 1 where no copy was ready
[LateGamePerformance] Last 1000 ticks. SoilScans: 2000 moisture and contamination passes in 200.0 ms (0.100 ms each); 97.0% of 8-tile groups had nothing changed and were passed over; 5400 changed cells updated
[LateGamePerformance] Last 1000 ticks. WaterRendering: 1000 updates switched water tiles 800 times where the game switches them 900000 times; 3000 of 6000 flow direction and flow limit uploads left out because the graphics card already had them
(The numbers are illustrations, not measurements.)
What was tested, and what was not
The harness passes against the installed game's assemblies; 73 patch targets resolve (15 new), none with an exception filter.
- Water map copy: two real
ThreadSafeWaterMaps over one realWaterSimulator, one ticking the game's way and one through the mod, for 16 ticks with water, flows and column counts moving, a layout change, a reset, a new water layer and a missing copy: the same bytes in both after every tick. Verify mode compares the same way: 0 mismatches. - Soil scans: the order of cells matches the game's loop on 90 random maps; over the real soil services, the game's per-cell method is called for the same cells, coordinates and levels in the same order. (The game's per-cell method cannot itself run in the harness, because the soil texture map it updates calls into Unity.)
- Water rendering: only that its patch targets resolve. It needs Unity's renderer, so it has not been tested at all.
- In the game: played and reported as working well. Not yet read: the new stats lines from that session, so the in-game savings are still unmeasured. Worth checking in your own game:
- The startup line shows
WaterMapCopy on, SoilScans on, and the log hasWaterTiles: enabled (3/3 patches)andWaterUploads: enabled (5/5 patches). - Water looks normal: surfaces, edges, waterfalls, flow patterns, contamination colour, and water appearing and draining. Take before/after screenshots of the same spot if you can. If anything looks wrong, set
WaterRendering = falseand sendPlayer.log. - The
WaterMapCopy:line mostly says "swapped in". For a check,WaterMapCopyVerify = trueandSoilScansVerify = trueshould giveverify mismatches 0. - In BeaverBuddies, the usual per-tick fingerprints stay identical on both computers.
- The startup line shows
Install
- Close Timberborn. Delete any older
LateGamePerformancefolder, then extractLateGamePerformance-0.4.14.zipintoDocuments/Timberborn/Mods. - Requires the Harmony (2.4.1+) and Mod Settings Workshop mods.
SHA-256 of the zip: 3586c4bb2f404fd94964587303bb801a424685a873b0139bebad2bfd582ec5f4