Faster roof scan and heat pass with identical results (t21)

- The roof is rescanned only in area columns that changed since the last scan: a quiet Huge
  world goes from 4.60 to 1.88 ms per scan (every 20 ticks).
- The heat pass skips react() for solids and powders below their first reaction threshold:
  Huge world digging 2.54 -> 2.34 ms/tick, quiet 1.39 -> 1.18.
- Every suite's output is identical apart from timing lines; seeds make the same worlds.
- test/t_sim_optimizations.js checks the dirty roof against a full scan and the heat loop
  against the reference loop byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 22:18:50 -04:00
co-authored by Claude Opus 5.5
parent d3fc1d2cbc
commit f57bdd6084
9 changed files with 160 additions and 11 deletions
+17
View File
@@ -4,6 +4,23 @@ What agents have done, newest first. Add an entry for every piece of work: the d
note or request it was for, what changed, the files touched, the tests run, and anything left
open or not verified. Keep each entry short; the git history has the details.
## 2026-10-24: t21 phase 3: speed-ups that change nothing (Claude Code, Codex)
- Profiled a Huge world (6144x2048) headless and in the browser. After a load every area is
awake: 8-15 ms/tick for the first 600 ticks, settling to about 0.7 ms/tick after 3 minutes. In
the browser, drawing is cheap; the full roof scan every 20 ticks was the largest single item.
- Kept: `updateDirtyRoof()` (`src/sim/ledger.js`) rescans only area columns marked by
`wakeXY`/`wakeHeatXY`/`simMove`/`heatChunk` (`roofDirty`); `updateRoof()` is still the full scan
for setup code. Quiet Huge world 4.60 -> 1.88 ms per scan, digging 4.67 -> 3.48.
`heatChunk` skips `react()` for solids and powders below their first reaction threshold
(`REACT_MIN`). Huge, ms/tick: digging 2.54 -> 2.34, quiet 1.39 -> 1.18.
- Reverted (no consistent gain): inlining `condPair`, one shared part rule for `enter`/`passable`.
- `test/t_sim_optimizations.js`: the dirty roof matches a full scan; `heatChunk` matches the
reference loop in `test/fixtures/heat-chunk.js` byte for byte, random state included (catches a
reaction added to `react()` but not to `REACT_MIN`).
- Every suite's output identical before and after apart from timings; seeds 777 and 4242
generate the same worlds. `run_all.py --browser` ALL PASSED.
## 2026-10-24: t21: piles near the bot sort quickly (Claude Code, Codex)
- Owner: "a pile should sort when the player is nearby. the sorting shouldnt take long anyway."