Page 1 of 1

Optimize UPS lag due to biter spawns

Posted: Wed Mar 27, 2019 4:36 am
by Brightstar
Apparently, when the bugs are blocked from attacking by terrain features, yet pollution causes them to spawn, massive framerate/UPS lag can result.

I'm using an AMD Ryzen 7 2700x Eight-Core processor (just upgraded) and an NVIDIA GeForce GTX 1070 (fairly recent hardware) with Windows 10 to run the game.

I'm not sure how to elucidate this further because I don't know exactly what is causing the problem except that if I use the "kill all enemies" console script my framerate goes from 20 up to 60 instantly.

There are so many different ways to fix this, the primary one I can think of being to batch pathing requests on biters.

Considering how much pollution grows when you start installing high level modules, this should receive some attention before 1.0 (I'd hope) because the game went from 60 FPS naturally to 20 as soon as I put in the tier 3 modules.

Thanks!

Re: Massive framerate/UPS lag due to biter spawns

Posted: Wed Mar 27, 2019 8:47 pm
by Rseding91
Can you please post a save file showing the slowdown problem?

Re: Massive framerate/UPS lag due to biter spawns

Posted: Thu Mar 28, 2019 12:25 am
by Brightstar
I tried to post one with the initial post (and will try to repost here).

Apparently my preferred file (where I'm getting 18 to 20 FPS) is too large. I'm going to try to post a smaller one where I'm getting ~40 fps on this post.

Re: Massive framerate/UPS lag due to biter spawns

Posted: Thu Mar 28, 2019 1:17 am
by Brightstar
OK, here's a dropbox link to my save file.

This is 130 MB, and runs at ~ 20 FPS for me right now.

It was too big to attach.

https://www.dropbox.com/s/c5cw27l9i2y4h ... t.zip?dl=0

Re: Massive framerate/UPS lag due to biter spawns

Posted: Thu Mar 28, 2019 10:38 am
by Stevetrov
I think you are experiencing the same problem as me, and I believe its related to artillery rather than pollution (although pollution can cause a similar problem, I have never seen pollution cause this much of an issue)

Here is my bug report:
viewtopic.php?f=182&t=64334&p=407346#p407346

As far as I can tell something like this is happening (I am not a factorio dev and dont have access to the source code so this is guess work based on nearly 20 years of dev experience):

* arty shoots nests
* biters form squads to retaliate
* Factorio limits the number of groups that can pathfind on a single tick so pathfinding doesnt consume too much CPU.
* Biters without paths stand around but remain active, these biters seem to collectively use a lot of CPU for an unknown reason.
* If the number of biters not getting paths grows faster than the biters dying against the players defences then the number of active biters grows and grows and UPS goes down and down.

But what is strange is that once the number of active biters hits some point the number of biters attacking actually decreases rather than staying the same asI would expect once we reach the path finding limit. Maybe processing the active biters reduces the number of pathfinds that can happen on a tick?

Other things of note, there are around 2000 unit groups in this save and 60,000 active biters (# active entities - #active entities once biters all killed off)

Re: Massive framerate/UPS lag due to biter spawns

Posted: Fri Mar 29, 2019 6:52 am
by Brightstar
Stevetrov,

The one issue I see with this is that I was getting massive FPS drops before I ever got artillery.

I intentionally built a map that would limit the bugs' access to me by changing water and cliff settings.

I got a huge amount of pollution overflowing my island and creating spawns before I ever started building artillery. Granted I'm seeing exactly what you said now that I have artillery out, but my other save (the 75MB one) has a drop to 40 FPS with zero artillery in the map.

Re: Massive framerate/UPS lag due to biter spawns

Posted: Tue Apr 23, 2019 10:09 am
by Stevetrov
> The one issue I see with this is that I was getting massive FPS drops before I ever got artillery.

The problem is too many active biters, there are 2 ways biters can turn active in large numbers (that I know of anyway). Thru artillery or thru pollution. With pollution its normally not a problem unless you have a map where the biters cant path thru to your base (like yours). With artillery its not too hard to create active biters faster than they die against your defences.

Re: Massive framerate/UPS lag due to biter spawns

Posted: Wed Apr 24, 2019 10:11 am
by Klonan
As far as I see, this is more a request for optimization, so I'm moving it to ideas and suggestions