Skip to content

A world no longer hangs while its railway is planned; perf gate: noise is not a slow build - #526

Merged
k06a merged 1 commit into
mainfrom
claude/project-thread-n5wg8s
Dec 2, 2026
Merged

k06a merged 1 commit into
mainfrom
claude/project-thread-n5wg8s

Conversation

@k06a

@k06a k06a commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Requested by Anton · project thread "Green main and a merge queue"

The hang (hotfix)

Rail.make (gw 71 and later) could plan a railway loop for ever: with one town left and no side of it that the grade suits, the same plan was asked again and again. A world with such a region next to it never came back: the game froze while the world was made, and since the start screen shows a world of a random seed, a fresh start could freeze too (in headless runs that is the Navigation timeout of 30000 ms of several tests, the tests killed after 25 minutes, and release runs that never end).

The fix is by the streets thread (it also sits in #499): every plan costs the loop a town or one of the four sides of its last town; no town left, no line. tools/rail.mjs test counts the plans of the three seeds that hung (5150 town+sea, 260429754 forest, 20261146 town): it fails on main and passes here. No world that came back before changes, so no golden hash moves and no generator number is needed.

The perf gate

Of 110 PR runs today where both sides were the same file, 65% ended "Slower than main". The verdict came from two turns of each build with the range of the two as the noise; with some forty comparisons a run that is a false alarm most of the time.

Now a difference counts by its size (tolerance and floor, as before) and only when the turns of the two builds stand apart, eight turns each (at most 3 of the 64 pairs the wrong way round: by chance once in 1840). Two turns are a first look: a scenario that looks slower gets two more turns of each build alone, until its turns mix or eight still stand apart. On simulated turns with the noise of a runner: the same build is called slower in 1% of runs, a scenario 30% slower is caught in 95% (tools/perf.test.mjs). The job keeps every turn's report as an artifact (perf-turns), so the real noise of the runners can be measured.

Tests that could not start

plan, villa, roomy: their hand-kept file lists lacked 09_core.js (PADB). hut: loads the whole game without a page (tools/gen/load.mjs) instead of a list that had fallen behind four files.

Checked

  • node tools/rail.mjs test: ok
  • node tools/perf.test.mjs: all passed; plan, villa, roomy, hut: ok
  • tools/perfgate.test.mjs (a build 10 ms a frame slower must fail the gate)

Generated by Claude Code

@k06a k06a self-assigned this Dec 2, 2026
…ells noise from a slow build; four plan tests load the game again

- Rail.make (35_track.js): every plan of a loop costs it a town or a side of its last town, so the planning ends (fix by the streets
  thread; seeds 5150, 260429754 and 20261146 never came back, the start screen froze on such a seed). tools/rail.mjs test counts the plans.
- tools/perf.lib.mjs: a difference counts when the turns of the two builds stand apart, eight turns each; two turns are a first look
  and a suspicion gets more turns of its scenario alone (ab). The same build failed 65% of the PR runs by the old rule.
  perf.yml keeps every turn's report as an artifact.
- plan, villa, roomy tests: 09_core.js in their file lists (PADB); hut.test loads the whole game instead of a hand-kept list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UiczdrPyoU594YpAeAd6En
@k06a
k06a force-pushed the claude/project-thread-n5wg8s branch from 5bb0f29 to 4eb9969 Compare December 2, 2026 22:46
@k06a
k06a merged commit 83f3284 into main Dec 2, 2026
2 checks passed
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

⏱ Performance: this PR against main

Scenarios of src/game/98_perf.js, the two builds by turns on one runner (tools/perf.mjs, CPU side, draws counted not drawn).

✅ No regression against main

scenario metric main PR Δ threshold turns
– no change beyond the noise
scenario CPU mean p95 max slow/min spikes/min miss sync gens draws top systems (ms/frame)
idle 5.59 8.80 47.1 3.75 22.4 0% 2.00 389 Town.update 0.81, Land.drawPass 0.65, BigMap.sample 0.49, Town.draw 0.39
night 4.16 7.25 16.3 0.00 5.99 0% 0.00 366 Town.update 0.53, Land.drawPass 0.49, Town.draw 0.35, BigMap.sample 0.30
drive 34.0 75.2 323 334 72.3 45% 97.5 121 Land.lightTick 13.1⚠️, Land.gen 4.30⚠️, Land.meshChunk 2.12⚠️, Land.lodData 1.67
flight 13.5 40.4 610 82.4 195 0% 39.5 50.5 Land.lodData 3.06, Folk.update 2.35, BigMap.sample 1.70, Land.gen 0.90⚠️
tunnel 11.8 45.4 277 89.6 169 0% 11.0 264 Land.lightTick 2.05⚠️, Land.lodData 1.42, Land.meshChunk 1.15⚠️, Folk.update 0.81

Over budget (ms/frame, budget): drive Land.lightTick 13.12 > 1 · drive Land.gen 4.30 > 0 · drive Land.meshChunk 2.12 > 1 · tunnel Land.lightTick 2.05 > 1 · flight Land.gen 0.90 > 0 · tunnel Land.gen 0.30 > 0 · drive gl.upload 0.97 > 0.8 · tunnel Land.meshChunk 1.15 > 1


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants