Repository navigation
Keep the Modern router's line costs and routes for the step - #2279
Conversation
The router read each boarding's line from three maps at every visit of every search, and riders weighing another way after an hour in one line asked the same route one after another. Each line's cost is now worked out once until a rider joins it or the step's lines change, and a route found since the lines last changed is reused. Routes come out the same: the conformance lock and the fuzz corpus do not move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ms7trYcRHkvnh6N2YZqqjw
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The docs preview for this pull request was removed when it closed. |
📸 Screenshot drift checkNo drift: the committed screenshots already match a fresh deterministic generation. ✅ |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Independent review at 806ec2a: GO (recorded after merge)This PR merged while the review was running, at the same commit I reviewed (806ec2a). Nothing here asks for a change. Review: stand-in-pr-review plus a lean The claim: no route changesChecked statically, then by a scratch probe (not committed). Statically. A Board link's cost reads three things:
I found no other path that writes those inputs. The changes counter starts at 1 and wraps with The probe. I added a kill switch that makes
Timing, 6 AM to 6 PM. Release build, best of 5 per run, two runs each:
The owner's tower is about 5% faster. The other two are within the container's noise, and neither is consistently slower. This only compares the cache against no cache at the same commit. The remaining cost of #2272 against 4.0 on the split tower (+8% by the PR's callgrind counts) is the follow-up the owner already accepted for 4.1. Gates at 806ec2a: Findings
Hot-path record (
|
| Item | Record |
|---|---|
| HP-1 Callers and tier | line_cost: per link visited in search (step tier, per route asked). The kept-route lookup in cheapest: once per ask. joined: once per join_line. all_changed: once per step from stand_down. number_lines: once per router build (command tier, a tower edit). |
| HP-2 Scans added | None per step. number_lines makes one pass over the links when the router is built. |
| HP-3 Nested or quadratic work | None. |
| HP-4 Allocation in the loop | A kept route is cloned on a hit and stored on a miss. The map is capped at MOST_ROUTES (1024) and cleared when full. |
| HP-5 Per-join cost | forget_routes clears the map on every join. The cost is proportional to its size, at most 1024 entries, and usually small because a join empties it. |
| HP-6 Memory | One (u32, i64) per Board line plus at most 1024 routes, a few hundred KiB at worst. Nothing is saved. |
| HP-7 Determinism | FastMap is used only for lookups and never iterated into output. Saves are identical cache on and off on three towers, checked hourly. |
| HP-8 Caches | Adds a cache that is equivalent to a fresh search. The module doc names what invalidates it, the probe above shows the equivalence, and no cache was dropped or bypassed. |
| HP-9 Measured | The table above shows the cache is no slower than no cache on any tower, and about 5% faster on the owner's. The PR's callgrind counts show split-16 going from +21% to +8% against main before #2272. |
| HP-10 Save, layout, binding | Unchanged. The cache isn't saved and is rebuilt empty after a load. |
| HP-11 Reload continuity | Holds. The cache starts empty after a load and the routes don't depend on it. |
| HP-12 Budgets | No bundle or install-size change. This is engine-only and adds no dependency. |
Verdict: GO at 806ec2a.
Generated by Claude Code
What & why
#2272 (riders stuck an hour in one line look for another way) made a Modern game day slower: about +15% on maxed Modern and +27% to +32% on the split tower, from the pre-4.1 perf check. This keeps the router's work for the step, with every route coming out as before:
expected_costs::line_cost).StepCosts::joined,all_changed).The owner chose to ship #2272 in 4.1 with this cache, and to follow up with further fixes that bring the split tower to no slower than before #2272.
Closes: n/a (no issue)
Type of change
Game mode impact
Only the Modern router uses these costs, and no route changes, so neither mode plays differently.
Quality gates
npm run typecheck(no TypeScript change)npm run lint(no TypeScript change)npm test(CI runs it)npm run build(CI runs it)Engine:
cargo fmt --check,cargo clippy --all-targets --features tooling,conformance -D warningsandcargo test --release --features conformancepass. The native conformance run passes every scenario, the fuzz corpus replays with no golden moved, andnpm run engine:compatleaves the compat record unchanged.New tests in
crowd/expected_costs_tests.rs:a_kept_line_cost_is_the_cost_its_line_gives: every link's kept cost equals a freshcost_of, after the step's count and after each rider joins.a_rider_joining_a_line_forgets_the_kept_routes: 400 riders join the express's line one by one; each route equals a fresh search, and the local wins in the end.a_route_asked_again_is_the_route_a_search_finds: every trip between 15 floors, asked, asked again and searched fresh, gives the same routes.The first two fail when
joinedstops pricing a line again or stops forgetting the routes.Versioning
.changesnote with the rightapp:andcrate:levels, or this PR changes no deployed pathpackages/verticopolis-engine/README.mdand/orengine-rs/CRATE_README.md, or read both and putreadmes: unchangedin the note, or this PR changes no engine sourceapp: patch(the game runs faster) andcrate: patch(engine source changes, no route, save, layout or interface does).readmes: unchanged.Complexity
expected_time::search(every Modern route search),cheapest,join_line(every rider routed in Modern),stand_down(once a step).mainbefore #2272mainafter #2272The split tower's remaining cost is the hour-long-wait searches themselves (about 2,500 a day that this cannot reuse). Wall time on the container is noisy; best of 5 over three rounds it reads about +6% on maxed Modern and +8% on the split tower against
mainbefore #2272.Hot-path record (section 6): this comes with the review.
Screenshots / recordings
None. No route changes, so nothing on screen moves.
Notes for reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ms7trYcRHkvnh6N2YZqqjw