Skip to content

Plan a visitor's way back without a route search in the crowd step #2

Open

Description

@maniator

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

  1. added
    perf
    engine-rs
    P3
    task
    on Nov 18, 2026
  2. maniator commented on Nov 19, 2026

    @maniator
    ContributorAuthor

    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

  3. added this to the 5.x milestone on Nov 19, 2026
  4. added
    P1
    and removed
    P3
    on Nov 19, 2026
  5. transferred this issue fromVerticopolis/webon Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1engine-rsperftask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions