perf: CA optimization — 18 FPS → 83 FPS (4.6× speedup) with ×5 world scale
- Cache active_chunks(): one allocation instead of 5 per tick - heat_transfer/gas_step/pressure_step: direct chunk array access (chunk.temps[idx], chunk.gas_*[idx], chunk.pressure[idx]) instead of grid.get_temp()/set_temp() (eliminates 5 chunk-lookups per cell) - In-place updated_this_tick reset via get_chunk_mut (no Cell copy, no mark_dirty) - light_step: gather sources first (one pass), skip if no sources, reduced radius (lava 25→12, fire 15→6), frequency 10→20 ticks - gas_step: skip chunks with no gas (gas_density all 0) - pressure_step: skip chunks with all atmospheric (128), add mark_dirty - pre_dirty: HashMap instead of Vec (O(1) lookup vs O(n) linear search) - Cross-chunk heat transfer: edge_temps pre-loaded before mutable borrow - Spread chunk save I/O: 1 chunk/tick instead of all every 60 ticks - All 185 tests + 14 scenarios pass - Benchmark: 82.7 FPS avg, p99 86ms (was 18 FPS, p99 442ms)
This commit is contained in:
+12
-12
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"mode": "graphics",
|
||||
"ticks": 60,
|
||||
"total_time_ms": 6710.1,
|
||||
"avg_fps": 8.9,
|
||||
"avg_frame_time_ms": 111.81,
|
||||
"p99_frame_time_ms": 1055.62,
|
||||
"min_frame_time_ms": 12.09,
|
||||
"ticks": 300,
|
||||
"total_time_ms": 3627.1,
|
||||
"avg_fps": 82.7,
|
||||
"avg_frame_time_ms": 12.06,
|
||||
"p99_frame_time_ms": 86.45,
|
||||
"min_frame_time_ms": 7.25,
|
||||
"subsystems": {
|
||||
"ca_step_avg_us": 103983,
|
||||
"ca_step_p99_us": 1048423,
|
||||
"ca_step_min_us": 5067,
|
||||
"render_avg_us": 4606,
|
||||
"render_p99_us": 15606,
|
||||
"render_min_us": 3928
|
||||
"ca_step_avg_us": 4927,
|
||||
"ca_step_p99_us": 79708,
|
||||
"ca_step_min_us": 698,
|
||||
"render_avg_us": 4154,
|
||||
"render_p99_us": 6411,
|
||||
"render_min_us": 3798
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user