Skip to content

[18ESP] Destination check walks the whole board on every action #12849

Description

@chrstas

Game 263552 is stuck. The pending action, a pass in the buy trains step, takes long enough that the inspector returns a 502, so the game cannot be advanced at all.

https://18xx.games/game/263552

Loading the game is not the bottleneck. Profiling attributes almost the entire request to Graph#compute and Part::Path#walk, reached from check_for_destination_connection. That check sits behind CheckDestinationConnection#actions, so it runs on every action rather than only when track is laid, and twice per request, once while looking for the step that handles the action and once in skip_steps. The graph it asks is a no_blocking one, so token blocking does not prune the walk and a single call covers the whole board.

Two things drive this independently. How expensive a single call is depends on the corporation: without token blocking, a corporation's own tokens no longer bound the walk, so corporations with few tokens are the most expensive ones, which is the opposite of what you would expect. How long it persists depends on whether the corporation ever connects, since destination_connected? is the only cheap exit. In 263552 GSSR can never reach its destination hex, so the walk runs on every action until the game ends. It also happens when the destination hex does have track: in 245301 the check for CRB keeps running and keeps getting slower as the map fills in.

This is not the loading path from #12579, and it is not validate_auto_actions: the action costs the same with and without it.

https://gist.github.com/chrstas/f9254c9846be8b1b6cc32f9ae5d0e85c

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions