Skip to content

A worker for phones (generator phase 2); towns with an estate plan again - #509

Merged
k06a merged 3 commits into
mainfrom
claude/project-thread-pafmdj
Dec 2, 2026
Merged

k06a merged 3 commits into
mainfrom
claude/project-thread-pafmdj

Conversation

@k06a

@k06a k06a commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Requested by Anton · project thread

What

1. Fix on main (build 481): towns with an estate did not plan. The version floor (#466) dropped the constant STR (always true since), the estates (#494), written before, still read it. Git merged them cleanly, the bundle built, and Settle.plan threw STR is not defined for every town with an estate, so its far tiles and columns never came. Fixed at the two reads.
New test tools/undef.test.mjs: the whole game as the build puts it together, scopes by terser, any free name that is not a global of the browser or the language fails. It found STR; it runs in 4 s.

2. Phase 2 of the generator plan (docs/WORLDGEN.md): a worker for phones. Measured before building:

  • A far-tile worker in headless Chromium after the cold scenario holds 29 MB (small caches) to 25–40 MB (full), heap and buffers; the code is ~16 MB of it.
  • A generator-only worker script would save ~8 MB per worker and needs the game's top-level wiring split. Not built.
  • The lever was the count: a worker was counted as 400 MB, so a phone (budget 140–480 MB) got none and made every column, far tile and town plan on its main thread.

Now LodPool.count(cores, budget) counts a worker at 45 MB and lets the workers take a third of the budget; the page's budget goes to the worker with the land, so the caches of a small device are small in the worker too. Tiles and columns are the same bytes.

iPhone profile (no deviceMemory, budget 260 MB), CPU 4× slower, cold before now
workers 0 1
the 3×3 around the camera ready 39.8 s 11.0 s
the whole land ready not within the scenario 52.6 s
renderer memory (PSS) after it 334 MB 303 MB

Emulated only: no real iPhone was tried. A page that dies for memory starts with a smaller budget (Mem.lvl): an iPhone keeps its worker after one death and has none after two.

3. tools/farrec.test.mjs builds its third world at the current versions (genv.test flagged gw 9 below the floor).

Tests

  • tools/undef.test.mjs (new): red on main with STR, green here.
  • tools/wcount.test.mjs (new, 406 checks): the table of devices, more memory never means fewer workers, a worker with a small budget keeps the small caches and makes the same bytes.
  • tools/wcost.bench.mjs (new): memory and cold times with PHONE=1 THROTTLE=4, NW=0 for none.
  • tools/mem.test.mjs: a phone now has exactly one worker of the pool and still fits its budget (it counts the pool's own threads; the hook also counted the watchdog and the mesher).
  • Local: conventions, undef, genv, gen:golden (1028), gen:workers (292), gen:townfast, wcount, farrec (195), mem:phone pass.

Sources

  • W3C Device Memory API (deviceMemory is coarse and absent in Safari, so the budget cannot come from it alone): https://www.w3.org/TR/device-memory/
  • web.dev, Adaptive loading (decide by measured device signals, not by a fixed guess): https://web.dev/articles/adaptive-loading-cds-2019
  • WebKit bug 256703, "[iOS] Wasm based WebApp … reproducibly jetsams" (iOS kills a web page that takes too much memory; I read only its title, so the worker is counted against the page's budget as a precaution): https://bugs.webkit.org/show_bug.cgi?id=256703
  • Chrome DevTools Protocol Runtime.getHeapUsage (backingStorageSize) and Emulation.setCPUThrottlingRate for the measurement.

Rules added to docs/ARCHITECTURE.md: "A thread is counted at what it measurably holds, and lives in its page's memory class" and "Every name the code uses is declared, checked over the whole source".

No screenshots: nothing on screen changes (the same tiles sooner).

https://claude.ai/code/session_01UiczdsWP38p6ohAsRYayXG


Generated by Claude Code

…easured cost, a worker lives in its page's memory class

Measured in headless Chromium after the cold scenario a worker holds 29-40 MB (heap and buffers); it was counted as 400 MB, so a phone
got none. Now 45 MB each within a third of the budget; the page's budget goes to the worker with the land (small caches there too).
iPhone profile, CPU 4x slower: the 3x3 around the camera 39.8 -> 11.0 s, the whole land not within the scenario -> 52.6 s.
tools/wcount.test.mjs, tools/wcost.bench.mjs; mem.test counts the threads of LodPool itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UiczdsWP38p6ohAsRYayXG
…as still read by the estates (every such town threw); undef.test finds any undeclared name in the whole source; farrec.test builds its third world above the floor

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UiczdsWP38p6ohAsRYayXG
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UiczdsWP38p6ohAsRYayXG
@k06a k06a self-assigned this Dec 2, 2026
@k06a k06a added the queue In the merge queue: lands on main by itself (node tools/merge.mjs <pr>) label Dec 2, 2026 — with Claude
k06a added a commit that referenced this pull request Dec 2, 2026
dev: hotfix for the freeze of build 481 (#509, build 484)
@k06a
k06a merged commit b107c73 into main Dec 2, 2026
1 of 2 checks passed
k06a pushed a commit that referenced this pull request Dec 2, 2026
…ps move to gw 77, build 482

- The gates of this branch (bends by bisectors, forks, bridge decks as ramps, track grass strip, ramps under snow, pixel-line markings) are one generator version, gw 77; SHAPE_GW and the other gates under the floor are gone with main's floor.
- Golden worlds of this branch pinned to gh 9 / gl 9 / gw 77; old hashes unchanged (1068 checks).
- Notes and release shots renumbered to 482 (tools/shots/482.mjs finds its bridges by rise instead of fixed road keys).
- 34_settle.js: estate lanes no longer read the removed STR flag (same two lines as in the estate fix of PR #509), without it towns with an estate threw during generation and drive.test could not run.

Checked on the merged tree: shape, deck (26 deck steps, 107 track steps), ramp, till snow, golden. drive.test per seed against the same build at gw 72: 56 / 50 / 66 / 46 runs with faults against 122 / 67 / 103 / 145 (seed 5150 town+river does not finish loading on main 481 either: Rail.reachW under Rail.make).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UiczdtfS3F7ut856jKPgvG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

queue In the merge queue: lands on main by itself (node tools/merge.mjs <pr>)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants