Friday Dev News #29 - Pathfinding Performance

Hello everyone!

After last week’s balancing changes, I found that people played longer and built larger cities. That’s great, but also brought some performance issues to light.

So I decided that this week I’d spend some time working on the game’s performance. These are the results of today’s update in one of the large saves I looked at:

  • save game size reduced from 92 MB to 24 MB
  • save game load time reduced from 2 minutes and 12 seconds to just 22 seconds
  • game speed improved from 10 fps to 20 fps

These results are all from my old laptop from 2016. Modern computers will be faster. Also, this is an exceptionally large city with more than 12.000 active cars. There are still a bunch of optimizations we haven’t done yet. Our target performance for the released game is a lot higher than 20 fps of course, even on older hardware :slight_smile:

Also, if you continue playing an older save, some of the improvements may need some time to kick in. You might need to save and reload once as well.

Advanced Pathfinding

One of the most expensive calculations in InfraSpace is pathfinding - that means finding out which path a car should take. For this update, I managed to speed it up by a factor of 3, but I think we can go even further.

I’m trying to use a method called “Contracted Hierarchies” to try to speed it up much more. Basically, it works by preprocessing some shortcuts for the pathfinding algorithm so it doesn’t have to look at many thousands of roads to find a route from A to B.

This is how it looks when the game shows all the shortcuts that are calculated:

Each blue line, each “shortcut”, speeds up the calculation because the computer doesn’t have to look at the roads between the start and the end of the shortcut to find the car’s path.

While initial results have been promising, it’s not completely ready yet, so I won’t release this new technique this week.

In the meantime, I hope the improvements so far are making your experience a little smoother :smiley:
Happy playing!

1 Like

Thanks for keeping us informed and providing the regular updates.

1 Like