Repository navigation
Make big towers cheaper to run, with every game the same - #2287
Conversation
The Metro jam fix (#2272) costs a tower in a long elevator jam extra route searches. This takes that back, and more, with exact speed-ups elsewhere in the step: the parking check fills room by room, lookup-only maps (demand pool, crew floors, commute averages, lobby reach, noise memo) use the fast hasher, the lobby distance walks the tall halls once, the landing lines read each shaft once per line and keep slots by place in the crowd, and the Modern router skips pricing a line when the link cannot win. Per game day (callgrind instructions, ticks only, one codegen unit), main before #2272 against this branch: split tower 2.240 G to 2.224 G, maxed Modern 5.408 G to 4.411 G, maxed Classic 2.705 G to 2.049 G. Conformance 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.
|
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. |
|
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. ✅ |
Independent review at 2bd4b3a: GOReview: stand-in-pr-review plus a lean Is every change exact? Read change by change
Is every change exact? The probe (scratch, not committed)The probe loads each tower and runs 30 game hours one second at a time. Every hour it prints:
I ran it on
The towers had 271, 534 and 534 parking spaces and up to 5,109 people, so the parking fill and the landing lines ran under load. Nothing slower: timingOne game day on each tower, load excluded. Each cell is the best of 3 within a run, with two runs per commit, interleaved.
The split tower is back to its speed before #2272, or slightly faster. Maxed Modern is about 30% faster and maxed Classic about 33% faster. This agrees with the PR's callgrind counts. Gates and CI
The test edits only follow the API: Findings
Hot-path record (
|
| Item | Record |
|---|---|
| HP-1 Callers and tier | Step and slice tier: search (every Modern route), landing_slots (once a slice), cost_of and line_cost, the housekeeping dispatch lookups, the demand map build, the lobby-reach sets (on a tower revision) and nearest_lobby_floor_distance (demand and satisfaction reads). Hour or day tier: functional_parking_set and functional_parking_spots. |
| HP-2 Scans added | None. The lobby distance goes from one ordered lookup per lobby floor to one merged walk of both sorted lists. The parking fill visits each room once instead of each tile. |
| HP-3 Nested or quadratic work | None added. A ramp's vertical pushes are per column, as before. |
| HP-4 Allocation in the loop | landing_slots allocates one Vec<Option<f64>> per slice (O(people)) in place of a map of waiting riders, and reuses one line_up buffer across lines. The search heap entry shrinks from 32 to 24 bytes. |
| HP-5 Hashing | std SipHash maps and sets become FastMap and FastSet on lookup-only paths. Neither hands out an iterator, so the order can't leak. |
| HP-6 Memory | Smaller or equal. floors_busy is flattened to one set, and the heap entry is smaller. |
| HP-7 Determinism | Saves are identical every hour for 30 hours on three towers against main. Nothing reads an iteration order. |
| HP-8 Caches | None dropped or bypassed. The prune skips filling the #2279 line cost only where the link cannot win. |
| HP-9 Measured | The table above shows no tower slower than main or than before #2272. |
| HP-10 Save, layout, binding | Unchanged. No saved field moved, and the hashes are equal. |
| HP-11 Reload continuity | Not affected. Nothing new is saved or rebuilt differently after a load. |
| HP-12 Budgets | Engine-only. No dependency added and no bundle change. |
Verdict: GO at 2bd4b3a.
Generated by Claude Code
What & why
The fast follow to #2272 and #2279 the owner asked for when 4.1 shipped with the Metro jam fix: bring the split tower back to no slower than before #2272. The hour-long-wait re-route still costs its searches, so this pays for them with exact speed-ups elsewhere in the step. Every game comes out the same.
functional_parking_setflood-filled tile by tile with a SipHash set, about 105 times a day. It now steps from room to room (a ramp still reaches the floors above and below each of its tiles) and counts with the fast hasher (Tower::reached_parking).DemandMap), the housekeeping crew maps, the commute averages, the lobby reach sets (seg_served,lobby_reach) and the noise memo move fromstdmaps toFastMap/FastSet. None of them is walked in hash order; the two that are listed (the commute averages in a save, a test sum) go throughsorted().nearest_lobby_floor_distancedid one ordered range lookup per lobby floor; both maps run up the tower, so one merged walk finds each floor's tallest hall.landing_slotsreads each shaft once per line instead of once per rider, sorts (wait, id, place) keys instead of chasing indices, and keeps each rider's slot by their place inCrowd::people(nobody leaves the list until the motion pass ends, and ids are unique) instead of in a map by id.u32, andline_costandToward::aheadare marked#[inline]so they stay inlined into the search however the crate's codegen units fall.cost_ofmoves toexpected_costs.rsbesideline_costto keepexpected_time.rsunder the 500-line ceiling.Closes: n/a (no issue)
Type of change
Game mode impact
Nothing plays differently in either mode; both get faster.
Quality gates
npm run typecheck(no TypeScript change)npm run lint(no TypeScript change)npm test(CI runs it; the file-size and Rust prose guards pass locally)npm run build(CI runs it)Engine:
cargo fmt --check,cargo clippy --all-targets -- -D warnings(with and without--features wasm) andcargo test --releasepass. The native conformance run passes every scenario, the fuzz corpus replays all 13 entries with no golden moved, andnpm run engine:compatleaves the compat record unchanged.Tests that hold the rewrites to the old behavior:
tower_reads_tests::the_parking_flood_seeds_from_the_ramps_alonecompares the room-by-room fill against a tile-by-tile reference walk through ramps on two floors, every unit state, a same-count swap and a reload.rule_tests::{lobby_distance, tall_lobby_distance, walking_penalties}cover the lobby distance with one-story and tall halls.landing_tests(updated to read slots by place) cover the line order and the back of the line.crowd/expected_costs_tests.rs(from Keep the Modern router's line costs and routes for the step #2279) checks kept costs and routes against fresh searches.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),crowd::landing::landing_slotsandmotion::step(every crowd step, every waiting rider),Tower::functional_parking_set/functional_parking_spots(service checks, about 105 a day),Tower::nearest_lobby_floor_distance(every unit's satisfaction pass),demand::compute_demand_map(hourly traffic income), housekeeping dispatch,graph::segment_connected/seg_reachable,noise_afflicted,record_commute.Simulation::tickonly, from callgrind):mainbefore #2272The default build splits the crate into 16 codegen units, and where they fall moves the router's inlining by up to about 1.5% between builds, so the one-codegen-unit rows compare the code itself.
Hot-path record (section 6): this comes with the review.
Screenshots / recordings
None. No route, position or count changes, so nothing on screen moves.
Notes for reviewers
best <= cost + own share <= cost + full cost).#[inline]on the transport lookup each ran more instructions here.Generated by Claude Code