Repository navigation
Description
What and why
When a visitor's time at a venue ends (a dinner, a movie, a shop), transition_to_return in engine-rs/src/crowd/motion.rs plans the way back inside the crowd step: crowd.route or doors::route_out_nearest, then routing::plan, and in Modern expected_time::fastest_path. On a route-cache miss that is a search over the route graph, run per person whose outing ends, inside the per-chunk crowd loop. HP-2 of docs/performance/hot-path-review.md does not allow a route-graph search at that tier. The goal-bound cache from Verticopolis/web#2246 cuts the work on a miss but does not remove the search, so the cost grows with how many outings end in a chunk and with the size of the route graph.
This is pre-existing: it is the same per-trip planning every trip start does, and main runs it at every outing end. Codex raised it on the review of Verticopolis/web#2482 (head 189f18f). That PR keeps one plan per outing end. A Modern office worker whose evening outing ends after hours now plans to the ground lobby instead of to the desk, and no longer makes the later desk-to-lobby trip, so the PR runs fewer searches in total. Measured on the save from Verticopolis/web#2481 (Modern, about 9,300 people, 4 game days at 0.5 minute steps, release build): 2.64 s on main, 2.40 s with Verticopolis/web#2482.
Not fixed in Verticopolis/web#2482 because the fix is a routing design change (planning the way back without a fresh search, while keeping the dynamic queue costs the Modern router prices), well past a bug fix.
Done when
A trip's way back costs no route-graph search inside the crowd step on a cache hit or a miss (for example the return leg is planned when the outing starts and re-priced cheaply, or misses are batched out of the chunk loop), the conformance lock and goldens are unchanged or moved with a reason, and a profile on the large tower and the Verticopolis/web#2481 save shows the step no slower.
Backlog row
crowd-return-route-search
Before submitting
- I searched existing issues and this is not a duplicate.
Generated by Claude Code
Activity
Defer the return-trip route search finding to #2484
maniator commentedon Nov 19, 2026
Triage (2026-11-19): moved from Triage to 4.x. It is a hot-path speedup in the crowd step, and perf work stays in 4.x. It ships only measured, with nothing slower.
Generated by Claude Code