Performance problem with pathing

Post your bugs and problems so we can fix them.
Post Reply
cliff_build
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Dec 03, 2020 4:52 pm
Contact:

Performance problem with pathing

Post by cliff_build »

During a recent Biter Battles game, performance completely cratered for ~30 seconds at one point (everything went to ~10 UPS for a while, and all clients with slower computers were eventually dropped for inability to keep up). I grabbed a save in the middle of this: https://drive.google.com/file/d/1CjDLvw ... sp=sharing and the slowness appears to all be in "entity update".

There are no mods loaded, and this is running the custom Biter Battles scenario code. I would love to know if this is some underlying issue with the pathfinder, or if we have somehow configured things poorly in the scenario.

The slowness is all coming from one group of biters (verified by deleting those biters in /editor mode) that is in the north-east under the fog of war. The biters are trying to navigate around/through some water and wall to get to some turrets.
I will note that we do slightly change some pathfinder settings, as visible here: https://github.com/Factorio-Biter-Battl ... /502/files Specifically, for an attack group like this, we are setting "unit.ai_settings.path_resolution_modifier = -1"
Group of biters that cause slowness
Group of biters that cause slowness
Screenshot of biter group.png (9.44 MiB) Viewed 322 times
.
Requested/required screenshot for performance issues
Requested/required screenshot for performance issues
Screenshot 2024-05-11 at 4.21.58 PM.png (2.94 MiB) Viewed 322 times
I am also including a screenshot with "show-detailed-info", which at least to me implies that the pathfinder is not doing huge amounts of work (we have had issues in the past where "Pather total: calls: xxx" shows a number in the millions that corresponds with lots of slowdown, but that doesn't seem to be happening here.
show detailed info.png
show detailed info.png (167.56 KiB) Viewed 322 times

ness056
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jul 24, 2022 3:47 pm
Contact:

Re: Performance problem with pathing

Post by ness056 »

Hello,
I just looked at the save. The problem is not the path finder, it is the stickers (taking 70ms per tick on averge on my computer). I first thought that the fire-spread would cause the lag, but disabling it with a mod doesn't change much. So I tried to make the damage interval bigger (to 90 ticks instead of 10) and it did reduce the lag. However, by playing the game tick per tick, the stickers were still making lag, either 0ms or a multiple of 7ms depending on the tick, this makes me think that each individual damage tick is taking 7ms to compute, tho I have absolutely no idea why it would take that long to apply damage to the biters. It would be nice if someone with deeper understanding of how the stickers work internally of the game engine can take a look.

Thank you in advance.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance problem with pathing

Post by Rseding91 »

This looks like it might be related to the scenario you're using and it changing path-finder settings. Every time one of the biters is damaged it calls for reinforcements which triggers a re-path.
If you want to get ahold of me I'm almost always on Discord.

cliff_build
Burner Inserter
Burner Inserter
Posts: 9
Joined: Thu Dec 03, 2020 4:52 pm
Contact:

Re: Performance problem with pathing

Post by cliff_build »

So it sounds like it could in fact be the pathfinder in some capacity, if the stickers are causing damage, and that damage is causing new path requests.

While I agree that, in theory, this could be due to the changes that our scenario makes to the pathfinder settings, if you actually load this save and watch it, the biters are completely stuck and performance is terrible, and then magically after some number of seconds things recover and the biters start moving. I don't even understand how changing the pathfinder settings could result in behavior like this. I also tried changing many of the pathfinder settings back to their default values in the save and it didn't appear to make any difference to the performance.

So I don't really understand how I can fix this, and it really feels to me like the underlying engine has some issue preventing pathfinding from working properly (the biters are just staying 100% still while they take damage).

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance problem with pathing

Post by Rseding91 »

I’ll look into it more tomorrow but from what I saw it seems like the cache count has been increased by a factor of 100, and then every time the biters are damaged they request a new path to the target. But before the new path can be completed they are damaged again and the old request is thrown out and a new one placed.

The slow part comes from the cache being so large it has to go over each cached entry to see if one is valid to use.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Bug Reports”