Performance optimization - post your saves

Post all other topics which do not belong to any other category.
Former Staff
Former Staff
Posts: 86
Joined: Fri Jun 24, 2016 2:29 pm

Re: Performance optimization - post your saves

Post by TOGoS »

mrvn wrote:
Thu Sep 01, 2022 12:46 pm
Am I missing something there?
You are not. Due to the terrain generator's nature as a massively SIMD virtual machine, it does not support lazily-evaluated function calls or if-else chains, meaning that every subexpression needs to be evaluated for each point on the map. Adding procedure delimiters probably won't help much in this case, since that only deduplicates the work of identical expressions across different named noise expressions (within one, identical subexpressions are automatically detected and only calculated once).

I can imagine solutions involving new, table-backed expression types, similar to spot noise, but that may have to wait until Factorio gets open-sourced (or someone gets me source access and a long vacation. :P)

Fast Inserter
Fast Inserter
Posts: 197
Joined: Fri Oct 05, 2018 4:34 pm

Re: Performance optimization - post your saves

Post by Hornwitser »

Slowdown with 200 long trains

I've built a 40 km long railway to get to those juicy 200M ore fields with default map gen options (call it a challenge if you may). To get the ore back to base there are about 200 trains moving at any given point in time consisting of 32 wagons each so that's about 6.4k wagons in motion. Unfortunately that seems to be too much for our server and it runs at about 49 UPS on this save. (For reference my underclocked Ryzen 3800x desktop does about 64 UPS on this save.) I had originally planned to build 3x 40 km fully saturated rails with 200 trains each to ship enough ore for 10kSPM, but now it looks like that's going to run at 16 UPS so that wont happen :(.

Save at

A casual look at visual studio's profiler shows Train::update using 75% of the game update.
image.png (144.97 KiB) Viewed 140 times

User avatar
Filter Inserter
Filter Inserter
Posts: 266
Joined: Sat Dec 09, 2017 6:01 pm

Re: Performance optimization - post your saves

Post by Muppet9010 »

Do you count continuous max pathfinder UPS for a few unit groups to get through many layers of walls as a performance issue ?
It only becomes an organic issue on very large bases, but can easily cause the pathfinder to stay at its max processing indefinitely.

Save that shows the pathfinder struggling. This map was being played with some light mods, but non affect pathing, units or the base, so save is without them. ...

I ask as in testing I found making the pathfinder focus more on going forwards helped it a lot in these situations.

Code: Select all

game.map_settings.path_finder.fwd2bwd_ratio = 20
game.map_settings.path_finder.goal_pressure_ratio = 5
If you apply the `fwd2bwd_ratio` and `goal_pressure_ratio` values above when loading the save, the current pathfinder requests all complete much faster than without. When measuring how long it takes for the 2 path requests on the east of the base (north east and south east) the ratio setting changes make the requests take 20% of the vanilla Factorio time. It does vary a bit between requests based on how straight on they are trying to meet across the wall.

Also increasing the tiny default cache sizes (short and long) to a massive number (1000) also helps a lot as it at least avoids the need to recalculate duplicate paths for a long time afterwards, although I appreciate that will have impact on how biters approach built obstructions on the map or make use of new landfilled paths. But biters will just bump in to new obstructions and attack it, and the UPS saving of this seems worth it in our larger MP games.

Code: Select all

game.map_settings.path_finder.short_cache_size = 1000
game.map_settings.path_finder.long_cache_size = 1000

Post Reply

Return to “General discussion”