Status: done
Priority: 1
Size: M
Arch: yardstick
Phase: implement
Design ref: Inheritance and expansion; People, households and family records (marriage). docs/roadmap.md, sections 5.2 (no step over 60 ms, Decided, Kim, 3 November; revised 6 November: small 60 ms, medium temporarily 400 ms until VB-201) and 5.3 (rule 5, stagger and spread).
Goal: In populous small at seed 7, the moving round takes 37 ms in one call at year 5. At year 40 it takes 485 to 539 ms called right after loading the save, and 897 ms in its place in year 41: the game freezes once a game year (3 November, this container). A CPU profile of one round on the year-40 save puts 444 of its 511 ms in heirRanking. Most of that is ownFirstOf (423 ms), which the round recomputes after every marriage, and handsOnWell, which ranks heirs again for each pair the marriage loop weighs (both, 382 ms). kinPressure takes 119 ms. Bring the longest step under 60 ms on small-y40 and temporarily under 400 ms on medium-y60; VB-201 restores medium to 60 ms. Blocked until VB-193 (the fixtures) is done.
Acceptance criteria:
own, places, handed, means in movingRound; the rankings kinPressure uses) are refreshed only for what a marriage changes: the two families’ households and the farms they hold or are first heirs to. They are no longer dropped whole after every marriage. tests/golden.json unchanged. The round’s time and roundRank (VB-192) on small-y40 and medium-y60 reported, before and after.medium-y60 (329.952 ms), so village scheduling is deferred to VB-201. When VB-201 changes ordering, preserve the original safeguards: plain-data progress, save/load determinism, exactly-once decisions, and 30-year demographic comparisons for populous small seeds 7 and 42 (marriages/year, first-marriage age, women 45–54 never married), each within 10%, before accepting golden changes.small-y40 (53.713 ms) and temporarily under 400 ms on medium-y60 (333.546 ms), timed as VB-088’s history check times steps. The earlier cache stage lowered roundRank and roundPairs growth baselines; this continuation lowers heirRank further and retains the ceiling for unchanged pair work.npm run verify passes.
Notes:node --cpu-prof). The round’s slowness is recomputation rather than its pass over pairs, so the fix that keeps behaviour comes first. Rule 2 (no pass over pairs) still applies to the marriage market, which weighs every man against every woman of the island: the scaling check (VB-088) shows its exponent, and slice 7’s encounters at venues are where matches will come from.Measurement note (VB-192 review, 4 November 2026): roundRank is a tools/tests measurement: snapshot VB.count.heirRank before Sim.movingRound(st) and subtract it afterwards. heirRank now counts every ranking at its source, including indirect calls; the simulation never reads it.
5 Nov 2026 (VB-193): unblocked; the four late-game fixtures are generated, verified and published on the orphan fixtures branch.
6 Nov 2026: partial implementation; still open. Selective ranking/cache invalidation and reuse preserve both complete late-fixture
post-round save hashes and the golden file. Rankings fall from 13,807 to 580 on small-y40 and 276,544 to 6,907 on medium-y60.
Direct calls fall from 336 to 77 ms and 14,544 to 328 ms; the round-day longest steps remain 51 and 482 ms, above budget.
A village scheduling experiment was removed: seed 7’s never-married cohort changed from 1/24 to 0/29, outside the required 10% band,
and medium still had steps over budget. No behavior change or golden update is retained. Full measurements, cost, impact and the
experiment’s 30-year demographic comparison are in docs/review-vb196.md; reproduce timings with node tools/moving-bench.js --day.
npm run verify: all 81 scripts pass, including browsers, golden states, saves, invariants, four fixtures and history. The longest-step
criterion and the conditional scheduling criterion remain unmet; the task is not marked done.
Follow-up investigation: docs/review-vb196.md now profiles the remaining stages and gives the ordered implementation and test gates.
The retained patch’s medium round spends about 149 ms in cached ranking reads and 80 ms in settlement. The failed scheduler could
retry men in its cross-village pass; it also needs explicit round union tracking and cache invalidation between slices. Fixing those
hazards is not proof that the demographic gate will pass. The literal one-final-step rule and the whole-day budget (including VB-201’s
separate midnight spike) need resolving before claiming completion. Added reusable stage profiling and 30-year demographic tools;
the demographic summary has regression cases for first unions, remarriage, death, age boundaries and empty cohorts.
Follow-up verification: all 82 scripts pass (225.1 s), including the new demographic regression. VB-196 remains open.
6 Nov 2026 (continuation from c27d72f): further behavior-preserving optimization: reuse ordered family traversal, stop propagating
unchanged direct claims, combine settlement radius searches, precompute field candidates and service eligibility. Full post-round
hashes still match on both late fixtures. Direct round times: small 92.0 → 53.7 ms, medium 440.9 → 330.0 ms; whole-day maxima:
61.2 → 53.7 ms and 513.8 → 333.5 ms. Source rankings: 580 → 577 and 6,907 → 6,680. Budget and scheduling remain unmet.
The separate medium midnight step is 215.9 ms. Bounded final steps and midnight scope have been raised with the user; the
demographic gate and golden file are unchanged. See the continuation section of docs/review-vb196.md for impact, evidence and tests.
Full verification: all 82 scripts pass in 254.3 s, including browser, golden, saves, invariants, fixtures and history checks.
6 Nov 2026 (user decision): raise the single-step timing gate from 50 to 60 ms and submit the current partial optimization as a PR. At the new gate, the measured small-y40 day passes (53.7 ms), but medium-y60 still fails (333.5 ms, plus a separate 215.9 ms midnight). Scheduling and the VB-201 dependency are deferred; neither is completed or waived. Existing demographic tolerances stay unchanged.
6 Nov 2026 (implementing the latest user decision): set a temporary 400 ms medium-y60 single-step gate, retaining 60 ms on small-y40. Both direct-round and whole-round-day measurements pass these gates. VB-196 is complete against this revised scope; scheduling, the strict medium 60 ms gate and the midnight spike move to VB-201. This is a temporary acceptance allowance, not a performance fix. Demographic tolerances, deterministic counter ceilings, daily and save/load budgets are unchanged.