perf: light_step source cap 64, minimap step_by(4), resize early-return, warning cleanup

- light_step: cap sources at 64 (was unlimited — 400+ lava cells = 250K ray-casts)
- minimap: step_by(4) sampling (65K→4K grid.get calls, still every frame — no flicker)
- resize(): early return if size unchanged (skip 350K element reallocation)
- Clean unused mut warning
- 172 FPS avg, p99 14ms (was 66 FPS, p99 180ms)
This commit is contained in:
Emil
2026-06-22 16:26:51 +03:00
parent 3e53d709f7
commit 93a6bcb35c
4 changed files with 23 additions and 14 deletions
+11 -11
View File
@@ -1,17 +1,17 @@
{
"mode": "graphics",
"ticks": 600,
"total_time_ms": 4648.7,
"avg_fps": 129.1,
"avg_frame_time_ms": 7.72,
"p99_frame_time_ms": 11.03,
"min_frame_time_ms": 7.13,
"total_time_ms": 3483.9,
"avg_fps": 172.2,
"avg_frame_time_ms": 5.78,
"p99_frame_time_ms": 14.20,
"min_frame_time_ms": 4.20,
"subsystems": {
"ca_step_avg_us": 1121,
"ca_step_p99_us": 1713,
"ca_step_min_us": 496,
"render_avg_us": 3543,
"render_p99_us": 4374,
"render_min_us": 3289
"ca_step_avg_us": 1397,
"ca_step_p99_us": 10172,
"ca_step_min_us": 303,
"render_avg_us": 3668,
"render_p99_us": 5514,
"render_min_us": 3259
}
}
+5 -2
View File
@@ -77,6 +77,9 @@ impl UiLayer {
}
pub fn resize(&mut self, w: usize, h: usize) {
if self.width == w && self.height == h && !self.cells.is_empty() {
return;
}
self.width = w;
self.height = h;
self.cells.clear();
@@ -324,8 +327,8 @@ impl UiLayer {
let mut g = 0u32;
let mut b = 0u32;
let mut n = 0u32;
for yy in 0..scale {
for xx in 0..scale {
for yy in (0..scale).step_by(4) {
for xx in (0..scale).step_by(4) {
let cell = grid.get(wx + xx, wy + yy);
if cell.material != MaterialId::Empty {
let c = cell.fg;
+6
View File
@@ -784,8 +784,14 @@ impl CellularAutomaton {
let idx = (ly as usize) * CHUNK_SIZE + (lx as usize);
if let Some((radius, color)) = material_light(chunk.cells[idx].material) {
sources.push((ox + lx, oy + ly, radius as i32, color));
if sources.len() >= 64 {
break;
}
}
}
if sources.len() >= 64 {
break;
}
}
}
}
+1 -1
View File
@@ -123,7 +123,7 @@ impl ChunkedGrid {
}
let key = (cx as i64, cy as i64);
if !self.chunks.contains_key(&key) {
let mut chunk = Chunk::new();
let chunk = Chunk::new();
if let Some(ref dir) = self.cache_dir {
let path = chunk_path(dir, self.seed, cx, cy);
if path.exists() {