-
Notifications
You must be signed in to change notification settings - Fork 185
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
Graph performance is very bad in worst case scenarios #10331
Comments
Firefox profiling shows the slowness coming from computing the graph during rendering, starting from the https://github.com/tobymao/18xx/blob/3794ce0dd/lib/engine/step/tracker.rb#L494 From there it's a pretty deep stack of |
18xx/lib/engine/step/tracker.rb Line 494 in 3794ce0
18xx/lib/engine/step/tracker.rb Line 468 in 3794ce0
Line 91 in 3794ce0
Lines 234 to 252 in 3794ce0
Line 39 in 3794ce0
|
Adding a bunch of temporary If that PR was already merged and this problem was encountered, identifying it as a graph problem would be as simple as adding |
The problem is something to do with the deletion on the converging check from #7788, removing these lines lets my browser compute the graph (probably not correctly) in about 0.02 seconds instead of 55 seconds: Line 86 in 5df8d6f
Line 178 in d1b2afa
|
…l possible ways Fixes tobymao#10331
…l possible ways Fixes tobymao#10331
Still have some failing tests, but I think I've got some progress on my |
I have some real progress on my There's still a lot of work to make it to support the custom args on The key part that will fix the algorithm for these bad cases isn't switching from DFS to BFS, but instead of the My graph also advances one function call at a time, instead of recursively traversing the whole graph. This enables visualizing the graph as it grows, and would be required for theoretical future features like persistent lazy graphs that don't get cleared, or bidirectional search for more efficient home-destination connection checking. |
In game 151565 the tile lays at action 536 and 537 on F19 and G20 raise the number of total While not adding any actual new connectivity for LNWR, these tile lays add a lot more converging exits, and they're first really big jump in the number of As the game progresses the number of calls gets huge. Action 650 upgrades Derby, adding another token slot to the city and unblocking LNWR. The I was hoping that finding the first big unnecessary jump in |
When a check is made to see if a corporation can run routes, |
It looks like these numbers are wrong, but the right numbers are still in the 100Ks if not millions. Looks like I was messing up the default argument when plumbing |
With #10951 I am actually getting the same endgame numbers at action 759 (LNWR's last turn of the game, in OR 8.1). Not sure why some of the earlier counts are different than what I was seeing before 🤷 |
Some good progress this weekend, I was able to configure 18GB to use my new adapter class instead of I can't step through the game yet to see how much that performance has improved, getting some errors I haven't had time to fix yet, but it's certainly coming along nicely! |
The real source of trouble appears to be in eliminating overlapping paths from |
Been a while since I've spent any time on this, but I think I'm still hung up on the overlapping problem from the previous comment. I think that seeing if the overlapping path connects back to a token without overlapping requires checking all possible routes from that path. I've tried thinking of clever ways to track more info as the graph is built, but that would end up being both time and memory intensive if you want every path/node to know about all possible paths to it. An alternate approach would be to rework the engine to stop auto-skipping steps so that the full graph doesn't need to be computed as much, and maybe getting rid of the highlighting in the UI for the track-laying step. |
Discussed in the site chat this morning:
I repro'd the slowness but haven't had time to profile or do a cursory investigation of whether the slowness is the game processing or the rendering. (also need to see whether the issue is specific to 18GB)
Copied the game data to this gist
Maybe similar? #10123
The text was updated successfully, but these errors were encountered: