Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorouter taking too long to time out #11252

Open
ollybh opened this issue Oct 3, 2024 · 2 comments · May be fixed by #11259
Open

Autorouter taking too long to time out #11252

ollybh opened this issue Oct 3, 2024 · 2 comments · May be fixed by #11259
Assignees
Labels
autorouting Issues relating to autorouting

Comments

@ollybh
Copy link
Collaborator

ollybh commented Oct 3, 2024

Issue #11239 was a report of being unable to select a route. This was probably caused by the autorouter being started and locking up the interface.

This occurred at action 792 of game 177538. This game exhibits horrendously bad autorouter performance: it is a game of 1858 which has Lawson track and a lot of tiles have been laid with many open cities. This means that the autorouter is going to struggle, but the problem here is that it is not timing out correctly: with the default setting of 30 seconds for path timeout, it took more than 10 hours to timeout on my desktop computer (which is far from being new or high-spec, but 😱).

D, [2024-09-30T22:26:36.021000] DEBUG -- : Rendering game view...
D, [2024-09-30T22:26:36.231000] DEBUG -- : Done rendering game view
D, [2024-09-30T22:26:39.094000] DEBUG -- : Path search: 0 / 57 - paths starting from L13
D, [2024-10-01T08:44:27.660000] DEBUG -- : Path timeout reached
D, [2024-10-01T08:44:27.661000] DEBUG -- : Evaluated 3791 paths, found 232 unique hexsides, and found valid routes 7E:3054 in: 37068.567
D, [2024-10-01T08:44:27.666000] DEBUG -- : Finding route combos of best 7E:3054 routes with depth 3054
D, [2024-10-01T08:44:27.892000] DEBUG -- : Found 741 possible combos (5 best) and rejected 0 conflicting combos in: 0.225
D, [2024-10-01T08:44:27.899000] DEBUG -- : Rendering game view...
D, [2024-10-01T08:44:50.770000] DEBUG -- : Done rendering game view
D, [2024-10-01T08:44:51.202000] DEBUG -- : Rendering game view...
D, [2024-10-01T08:45:14.141000] DEBUG -- : Done rendering game view

The path timeout is checked once in the autorouter's outer loop, iterating over the corporation's reachable nodes and looking at the potential routes from each. In this case it took multiple hours to check the nodes from the first node, and then only timed out when moving onto the second node.

Moving the timeout check into an inner loop won't fix the performance of the autorouter, but will at least means it times out much more quickly.

@ollybh ollybh added the autorouting Issues relating to autorouting label Oct 3, 2024
@ollybh
Copy link
Collaborator Author

ollybh commented Oct 3, 2024

Gist containing the game data for game 177538, up to action 792.

@scottredracecar
Copy link
Collaborator

scottredracecar commented Oct 3, 2024 via email

@ollybh ollybh self-assigned this Oct 4, 2024
ollybh added a commit to ollybh/18xx that referenced this issue Oct 6, 2024
The auto-router's path timeout is supposed to stop too much time being
spent on building up the set of possible routes for trains. It was being
checked once in each iteration of possible starting nodes for routes.

However, in particularly degenerate cases this meant that far too long
was elapsing between timeout checks: issue tobymao#11252 had more than
ten hours pass before the first and second timeout checks.

This moves the timeout check to an inner loop, so it is checked more
frequently.
@ollybh ollybh linked a pull request Oct 6, 2024 that will close this issue
3 tasks
ollybh added a commit to ollybh/18xx that referenced this issue Oct 6, 2024
The auto-router's path timeout is supposed to stop too much time being
spent on building up the set of possible routes for trains. It was being
checked once in each iteration of possible starting nodes for routes.

However, in particularly degenerate cases this meant that far too long
was elapsing between timeout checks: issue tobymao#11252 had more than
ten hours pass before the first and second timeout checks.

This moves the timeout check to an inner loop, so it is checked more
frequently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autorouting Issues relating to autorouting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants