BatchBuildRefresh
建造刷新合并: drone construction no longer redoes GPU, terrain, belt and power display refreshes for every building — once per frame instead (24 -> 32 ticks/s while building); belt lines trimmed to size on load (over 10 GB less memory in big saves).
| Last updated | a day ago |
| Total downloads | 63 |
| Total rating | 0 |
| Categories | Blueprints Optimization Quality of Life |
| Dependency string | DSPCraftingSpeed-BatchBuildRefresh-1.3.0 |
| Dependants | 0 other packages depend on this package |
This mod requires the following mods to function
README
Batch Build Refresh(建造刷新合并)
Large builds by construction drones no longer slow the game down with render refreshes repeated for every single building. 无人机大批建造时,游戏不再为每个建好的建筑都把画面刷新一遍,建造时明显不那么卡。
Since 1.3.0 it also gives back the memory belt lines keep after big builds: on load, every belt line's arrays are sized to its length (more than 10 GB less in big saves). 读档时把传送带收紧到够用的大小,大存档能少占十几 GB 内存。
Nothing about what gets built, or how the factory runs, changes. Remove the mod any time: the only trace in a save is a smaller belt capacity number, which the game reads as usual and grows again when a belt needs it.
What was slow
Measured in a running game (130 000 unbuilt buildings, 117 drones): finishing one building
(PlanetFactory.BuildFinally) cost 3.6 ms on the main thread, and almost all of it was render-side work done
again for every building:
| per building | |
|---|---|
upload every instanced model buffer to the GPU (SyncAllGPUBuffer) |
0.98 ms |
rebuild the terrain meshes (UpdateDirtyMeshes), plus heightmap texture and land percentage when terrain changed |
0.5 ms + 2.7 ms / 0.5 ms |
recompute the texture coordinates of the whole belt line (RefreshPathUV) — longer lines cost more |
0.6 ms per belt |
refresh the power display of the whole planet (RefreshPowerConsumers) |
0.54 ms per powered building |
On top of that, the connection display of unbuilt buildings (ConnGizmoRenderer.Update) re-walked every unbuilt
building on the planet in every frame in which anything was built (7–17 ms a frame).
What the mod does
-
Batching. While drones finish buildings (
ConstructionSystem.ExecuteBuildTasks), the four refreshes above only note what has to be refreshed. Once per frame — after all logic ticks of the frame, before anything is drawn — each dirty belt line, power display, terrain mesh and GPU buffer is refreshed once, in the order the game uses. Terrain data (heights) is still written immediately, so the factory logic sees exactly the same terrain. The belt display buffers of the planet, which the game re-uploads in full after every refreshed belt line, are uploaded once at the end (1.1.0: the batched refresh went from ~18 ms to ~6.5 ms a frame on a big build site). -
Connection display throttle. On planets with at least
MinUnbuiltunbuilt buildings the connection display refreshes at most everyIntervalseconds. While you drag a belt yourself it refreshes immediately as usual. -
Several kinds per hand-out (1.2.0). Before drones can fly, the mecha hands each unbuilt building its item (
ConstructionModuleComponent.PlaceItems, every 30 logic ticks) — but only for one building kind per hand-out, taking the kinds in turn. With five kinds in range the last one waited five hand-outs, about 5 seconds when a big save runs at half speed. Now each hand-out does up toKindsPerHandoutkinds (the game's own routine run that many times in a row, so other mods' changes to it still apply). One hand-out costs about 0.2 ms. -
Belt capacity trim (1.3.0). A belt line (
CargoPath) starts with room for 200 cells and doubles that whenever it grows — but never shrinks: when a line is cut or split, the big arrays stay. The save stores that capacity and loading allocates it again, so the slack lives forever. Each cell of capacity costs 29 bytes (cargo byte, position, rotation). Blueprint pastes are the worst case, since lines are built belt by belt, joined, grown and cut. Measured in a big save (339 252 belt lines): total length 164 million cells, capacity 883 million — 24.9 GB of memory, about 17 GB of it never used. With the mod, when a save loads, the capacity stored for a line is not allocated; the arrays are created right after the line's length is read, at the size the game's own doubling would have reached (200 · 2ⁿ ≥ length), never larger than the saved capacity. Works with LossyCompression (which reads belts with its own copy of the game's code). Takes effect at the next load.
Measured (same game, same build site, 80 frames each)
| vanilla | with the mod | |
|---|---|---|
| logic ticks a second | 24.2 | 32.3 |
| frame time | 74.7 ms | 51.0 ms |
| finishing buildings, per tick | 12.3 ms | 1.8 ms |
| connection display, per frame | 7.7 ms | 1.2 ms |
About 8 000 buildings were batched in the test without an error. Without construction going on the mod does nothing.
Config (BepInEx/config/com.github.jiesiluo.batchbuildrefresh.cfg)
| key | default | |
|---|---|---|
General / Enabled |
true | batching (1) |
ConnGizmo / Throttle |
true | connection display throttle (2) |
ConnGizmo / Interval |
0.5 | seconds between two refreshes of the connection display |
ConnGizmo / MinUnbuilt |
2000 | throttle only on planets with at least this many unbuilt buildings |
Handout / KindsPerHandout |
6 | building kinds per hand-out (3); 1 = the game's behaviour |
Memory / TrimBeltCapacity |
true | belt capacity trim (4); takes effect at the next load |
All other settings take effect at once.