[2.0.15] Demolishers take a disproportionate amount of cpu time

Post your bugs and problems so we can fix them.
djugei
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Nov 07, 2024 9:32 pm
Contact:

[2.0.15] Demolishers take a disproportionate amount of cpu time

Post by djugei »

Space Age has somewhat bad performance on my device, so i investigated a bit.
the show-entity-time-usage debug view shows that a disproportionate amount of time is used for AsteroidCollector and SmokeWithTrigger, additionally a big amount of time is used for Inserter.
This is about SmokeWithTrigger. Investigating the game files i found a rather low amount of mentions of smoke-with-trigger. Specifically found some related to demolishers.
To test my theory of demolisher involvement i killed all demolishers using a command. this made SmokeWithTrigger take 0ms in updates and made factorio --benchmark go from 15 to 13 ms.

It therefore seems that demolishers cause a big amount of cpu work even while not useful.

proposals to fix:
* only spawn the smoke if a player or player-controlled entity is close by, alternatively spawn graphical (no-effect) smoke all the time and then switch it once players get close to preserve visuals.
* reduce the amount of time the checks take. right now i assume that each smoke cloud checks each entity for being an enemy and not having the slowdown effect yet. specifically this would consider each segment of the demolisher. to fix that either some faster/better filtering could be used, or, since unlike poison capsules the effect does not stack, a single check could be done for each group of smokes, or both.
Sakari119
Long Handed Inserter
Long Handed Inserter
Posts: 58
Joined: Sun Oct 22, 2017 9:47 am
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by Sakari119 »

An extension of the proposal is as follows;
A hacky solution is that the generation of the volcanic ash and magma trail is not needed when there are no player controlled entities.
11-08-2024, 17-42-13.png
11-08-2024, 17-42-13.png (112.47 KiB) Viewed 666 times
Example of behavior where the blue boxed star represents a player structure, and red represents active worms with trails. Grey represents worms without trails been created.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14247
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by Rseding91 »

Can you provide a save file that I can test with?
If you want to get ahold of me I'm almost always on Discord.
Wadiyatalkinabeet
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Nov 09, 2024 11:49 pm
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by Wadiyatalkinabeet »

Hi Rseding91,

I have noticed this happening on my save (attached)
After killing all demolishers with a command, the ms/tick drops from ~13 to ~8
11-10-2024, 10-29-14.png
11-10-2024, 10-29-14.png (644.42 KiB) Viewed 482 times
->
11-10-2024, 10-30-10.png
11-10-2024, 10-30-10.png (619.16 KiB) Viewed 482 times
Attachments
space_age_together_79h.zip
(53.68 MiB) Downloaded 5 times
djugei
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Nov 07, 2024 9:32 pm
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by djugei »

thanks for providing an example, here is the original one, it still has the same issue even though vulcanus is more round.

first upload did not work out, so i deleted surfaces and blueprints, its about half the size now and the upload worked.
Attachments
assemblystorm_with_demos.zip
(79.42 MiB) Downloaded 10 times
Caddrel
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sun Oct 27, 2024 10:14 am
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by Caddrel »

Very useful thread, I was also wondering also what "SmokeWithTrigger" was.

On our game it's taking up a non-trivial amount of update time: viewtopic.php?f=49&t=121399

(admittedly there are lots of other things taking far more)

Save file attached to that thread. We also have the other culprits mentioned in the OP (inserters and asteroid collectors).

SmokeWithTrigger is taking up the same time as all the assemblers we have going, apparently.
User avatar
GregoriusT
Filter Inserter
Filter Inserter
Posts: 333
Joined: Wed Apr 10, 2019 6:42 pm
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by GregoriusT »

Still the case in 2.0.20 by the way. One of my Friends is having this exact Issue causing Lag.
Don't underestimate Landmines!
Biters bite, Spitters spit, Spawners spawn and Worms... worm? - No, they throw their vomit! They even wind up to directly hurl it at you! friggin Hurlers...
OvermindDL1
Fast Inserter
Fast Inserter
Posts: 193
Joined: Sun Oct 05, 2014 6:12 am
Contact:

Re: [2.0.20] Demolishers take a disproportionate amount of cpu time

Post by OvermindDL1 »

Currently [2.0.20], SmokeWithTrigger is eating around 1.2ms when normal in the game, and spikes to over 3ms (over 5ms in a few cases) when someone decides to go attack a demolisher or more and persists until a minute or so after they're dead. That's enough to cause it to drop below 60UPS for some clients, impacting their framerate down to the low single-digits before the UPS itself starts faltering and they build substantial buffer until the game has to be paused for them to catch up or the source of this is killed off and then wait a minute after, though by that point there's a lot of 'wait' built up and a large buffer so interacting with game is rather painful and jerky and extremely delayed when they are trying to, say, run for their life and their character doesn't want to move. This is on computers that handled, for example, a couple of dozen settled planets with very large active factories on ~12 of them with ~40 active ships in Factorio 1.1 Space Exploration without dipping below 60UPS. Even when not under attack the UPS is sustaining at 60UPS on those clients, however their FPS is dropping to between 15 to 35 FPS to keep the UPS at 60 (16 core systems at that, though it seems only 2 cores are in decently heavy use by factorio).

We've been trying to go on a long distance rampage to kill demolishers (attracting via artillery and killing at our base) without spawning more territory to help, and it does seem to be doing though, albeit slowly (there's multiple dozens of demolishers active on Vulcanus currently due to earlier exploration). The server is keeping up (barely it seems, but it is), just some clients aren't even though they aren't on that old of systems (as indicated above).

Closely watching the timings is what led us to the SmokeWithTrigger values spiking at certain times that correlated with the intense lag, and searching on these forums led us to that being the 'cloud' effects at the demolishers, which is what led to us starting to slaughter them from a distance (to not spawn more) and confirming that them using those clouds in force substantially effects UPS. Considering the persistent SmokeWithTrigger costs happening when one is not being attacked, I'm theorizing that they have such an effect around them in general?

SmokeWithTrigger is not the only high value, but it is the highest. The next highest entity timing is inserters and then assemblers at around 1.5ms and 1.3ms, but they don't jerk around and are fairly consistent. Electricity network timing is also up there at 1.2ms if I recall right (we know to keep each surface to 1 electrical network only as spamming electrical networks is a surefire way to lag the game to death, at least in 1.1 and before).
TheCherry
Burner Inserter
Burner Inserter
Posts: 11
Joined: Fri Jan 18, 2019 10:00 am
Contact:

Re: [2.0.20] Demolishers take a disproportionate amount of cpu time

Post by TheCherry »

OvermindDL1 wrote: Tue Nov 19, 2024 7:24 am Currently [2.0.20], SmokeWithTrigger is eating around 1.2ms when normal in the game, and spikes to over 3ms (over 5ms in a few cases) when someone decides to
....
We have exactly the same issues. Yesterday we reached vulcano and explored the planet, if we come now near to a big demolisher, my FPS drops to 5.
Overall is the performance very bad atm.
11-19-2024, 11-02-11.png
11-19-2024, 11-02-11.png (11.44 KiB) Viewed 137 times
Added our savefile
Attachments
nightraiders.zip
(78.49 MiB) Downloaded 2 times
TheCherry
Burner Inserter
Burner Inserter
Posts: 11
Joined: Fri Jan 18, 2019 10:00 am
Contact:

Re: [2.0.15] Demolishers take a disproportionate amount of cpu time

Post by TheCherry »

I looked into the code, I think you should give the demolisher a extra simple hitbox, this clouds with all that triggers and low cooldowns is very overshot.
I am not a game dev and I am not deep in the factorio modding, but this cloud stuff with expending and repeats - combined with a nested collision actions seems not a good way to design it. I think you have to refactor this part and add very simple hitboxes around that enemy that just stick to it.

I don't know if that helps. Sry if not.
Post Reply

Return to “Bug Reports”