Page 1 of 1

[1.1.6] High UPS drop with forest fires

Posted: Tue Dec 29, 2020 1:53 am
by blargh2015
Disclaimer: This is a modded game.

We are experiencing VERY high UPS performance hits with even small forest fires after upgrading from 1.0 to 1.1.6, to the point that I'm having to almost constantly do a "for k,v in pairs(game.player.surface.find_entities_filtered{type="fire"}) do v.destroy() end" console command, which immediately brings the UPS back up to 60. Debug blames Entity updates during this time.

This is made worse by the Rampant mod having fire-spitting biters and map settings that had relatively dense forests, so the little buggers are always setting off forest fires.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Dec 29, 2020 6:33 am
by Klonan
I don't see anything that looks like a bug

probably some mod is changing the fire entities to do some crazy large area of effect damage or something

Re: [1.1.6] High UPS drop with forest fires

Posted: Thu Dec 31, 2020 5:23 am
by ptx0
i have a mod called wildfire season and you could i guess, use it to reduce the fire hop limit so the fires are less intense. or try disabling smoke.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 3:44 pm
by blargh2015
After binary-tree-searching through our mods, it turned out Water Turret was the culprit here, which I suppose makes sense. Just weird it didn't show as the culprit on the detailed time listing.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 4:02 pm
by Pi-C
blargh2015 wrote:
Tue Jan 19, 2021 3:44 pm
After binary-tree-searching through our mods, it turned out Water Turret was the culprit here, which I suppose makes sense. Just weird it didn't show as the culprit on the detailed time listing.
Oh, geez! I thought I'd improved performance somewhat, and I've honestly no idea what more I could do. But it's true, whenever a fire is created it will spawn a dummy (which will be removed again together with the fire). Currently, I use combat bots (if I remember correctly, they are made inactive on being created) because I need an entity-with-force so the turrets can target it, but it may not be a simple-entity-with-force because that's attacked by artillery. If only we had target_masks for some more prototypes! :mrgreen:

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 5:16 pm
by blargh2015
Pi-C wrote:
Tue Jan 19, 2021 4:02 pm
Oh, geez! I thought I'd improved performance somewhat, and I've honestly no idea what more I could do. But it's true, whenever a fire is created it will spawn a dummy (which will be removed again together with the fire). Currently, I use combat bots (if I remember correctly, they are made inactive on being created) because I need an entity-with-force so the turrets can target it, but it may not be a simple-entity-with-force because that's attacked by artillery. If only we had target_masks for some more prototypes! :mrgreen:
A mitigating issue is probably that I got sick of people I'm playing with complaining "there aren't enough trees" so increased the tree density to its absolute maximum. It is SERIOUSLY a ridiculous amount of woodland. Then add in the Rampant mod that has biters that spit fire and the buggers just start forest fires all over the place, and having thousands of trees on fire happened pretty regularly.

However, we were getting the UPS slowdowns even when the fires were very far away from our water turrets - I don't know if there can be a range limit or somesuch put on finding fires and the dummy units? Would help a lot, at least in this case.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 5:17 pm
by ptx0
Pi-C wrote:
Tue Jan 19, 2021 4:02 pm
blargh2015 wrote:
Tue Jan 19, 2021 3:44 pm
After binary-tree-searching through our mods, it turned out Water Turret was the culprit here, which I suppose makes sense. Just weird it didn't show as the culprit on the detailed time listing.
Oh, geez! I thought I'd improved performance somewhat, and I've honestly no idea what more I could do. But it's true, whenever a fire is created it will spawn a dummy (which will be removed again together with the fire). Currently, I use combat bots (if I remember correctly, they are made inactive on being created) because I need an entity-with-force so the turrets can target it, but it may not be a simple-entity-with-force because that's attacked by artillery. If only we had target_masks for some more prototypes! :mrgreen:
what if you change the tree force to enemy (once it's on fire)?

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 5:21 pm
by blargh2015
ptx0 wrote:
Tue Jan 19, 2021 5:17 pm
what if you change the tree force to enemy (once it's on fire)?
I think that would cause every turret type to target them? So flamethrower turrrets ("YOU'RE NOT HELPING!!!"), snipers, artillery, etc...

The idea of flamethrower turrets attacking forest fires is unreasonably hilarious to me for some reason :)

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 6:04 pm
by Pi-C
ptx0 wrote:
Tue Jan 19, 2021 5:17 pm
Pi-C wrote:
Tue Jan 19, 2021 4:02 pm
blargh2015 wrote:
Tue Jan 19, 2021 3:44 pm
After binary-tree-searching through our mods, it turned out Water Turret was the culprit here, which I suppose makes sense. Just weird it didn't show as the culprit on the detailed time listing.
Oh, geez! I thought I'd improved performance somewhat, and I've honestly no idea what more I could do. But it's true, whenever a fire is created it will spawn a dummy (which will be removed again together with the fire). Currently, I use combat bots (if I remember correctly, they are made inactive on being created) because I need an entity-with-force so the turrets can target it, but it may not be a simple-entity-with-force because that's attacked by artillery. If only we had target_masks for some more prototypes! :mrgreen:
what if you change the tree force to enemy (once it's on fire)?
It's not the trees or the fires that get attacked, but the dummies. They are on their own force (which is hostile towards any force with players, and on ceasefire with all other forces, so that biters won't take out the fires for you), and unless another mod that's loaded after Water Turrets changes things again, they have a trigger_target_mask that will be ignored by all other turrets (except for artillery turrets, because these don't support target masks for whatever reason).

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 6:24 pm
by Pi-C
blargh2015 wrote:
Tue Jan 19, 2021 5:16 pm
However, we were getting the UPS slowdowns even when the fires were very far away from our water turrets
Technically, the acid splashes made by spitters and worms are just fires as well (based on the fire prototype), so if the option to clean acid is on, that may be the reason.
blargh2015 wrote:
Tue Jan 19, 2021 5:16 pm
I don't know if there can be a range limit or somesuch put on finding fires and the dummy units? Would help a lot, at least in this case.
We've come a long way! In the first version of firefighting water turrets, I did indeed search in a radius around each turrets for fires, which was incredibly inefficient. Now I don't need to search for fires at all: they announce themselves because I've modified all fire prototypes to autospawn a dummy. When a dummy is spawned, I look for the fire on the dummy position and create a custom entity for it. When the dummy is killed, fires around it are destroyed (along with the respective dummies), and if a fire expires of its own before the dummy could be killed, the dummy will simply be removed. The dummies are hardcoded in the attack_target_masks of the water turrets. Whenever a fire is created in range of a water turret, it will be attacked automatically, so I leave searching for dummies to the game engine. There are options like "attack target with least/most health" that require intervention per script, but these should be off per default.

Perhaps I'm missing something, but I believe I've optimized pretty much everything that took a hefty bite out of UPS.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 6:43 pm
by Pi-C
blargh2015 wrote:
Tue Jan 19, 2021 5:16 pm
… increased the tree density to its absolute maximum. …
You could edit settings.lua (lines 178--185):

Code: Select all

  {   -- Set radius in which fires are extinguished around a fire dummy
    type = "double-setting",
    name = "WT-fire-extinguish-radius",
    setting_type = "runtime-global",
    allowed_values = {1, 1.5, 2, 2.5, 3, 3.5, 4},
    default_value = 2.5,
    order = "WT-[misc]-[fire-extinguishing-radius]"
  },
You could add to or change "allowed_values", to extend the radius (no idea what a sane value would be: 6, 7, even more?). If one dummy is killed, all fires in this radius will be removed. It certainly will look ridiculous if a single turret can extinguish fires in a big area, but if there are so many trees that would take off some load. Turning up the damage should also help (turrets waste less time per fire, and the fires have less time to spread).

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 8:27 pm
by blargh2015
Pi-C wrote:
Tue Jan 19, 2021 6:43 pm
blargh2015 wrote:
Tue Jan 19, 2021 5:16 pm
… increased the tree density to its absolute maximum. …
You could edit settings.lua (lines 178--185):

Code: Select all

  {   -- Set radius in which fires are extinguished around a fire dummy
    type = "double-setting",
    name = "WT-fire-extinguish-radius",
    setting_type = "runtime-global",
    allowed_values = {1, 1.5, 2, 2.5, 3, 3.5, 4},
    default_value = 2.5,
    order = "WT-[misc]-[fire-extinguishing-radius]"
  },
You could add to or change "allowed_values", to extend the radius (no idea what a sane value would be: 6, 7, even more?). If one dummy is killed, all fires in this radius will be removed. It certainly will look ridiculous if a single turret can extinguish fires in a big area, but if there are so many trees that would take off some load. Turning up the damage should also help (turrets waste less time per fire, and the fires have less time to spread).
I'll give it a look. Our main point of deploying the water turrets was to try and deal with the overwhelming forest fires, so our solution will PROBABLY be "Okay Blargh2015, you made your point, turn the tree density back down." :)

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 8:56 pm
by ptx0
blargh2015 wrote:
Tue Jan 19, 2021 8:27 pm
I'll give it a look. Our main point of deploying the water turrets was to try and deal with the overwhelming forest fires, so our solution will PROBABLY be "Okay Blargh2015, you made your point, turn the tree density back down." :)
this is what i was recommending my Wildfire Season mod for, to tune down the fire hop limit, which is how far a fire can spread from the first tree that burned. you can set it to 1 or 2, and that will make fires less devastating with high tree count.

Re: [1.1.6] High UPS drop with forest fires

Posted: Tue Jan 19, 2021 9:30 pm
by blargh2015
ptx0 wrote:
Tue Jan 19, 2021 8:56 pm
blargh2015 wrote:
Tue Jan 19, 2021 8:27 pm
I'll give it a look. Our main point of deploying the water turrets was to try and deal with the overwhelming forest fires, so our solution will PROBABLY be "Okay Blargh2015, you made your point, turn the tree density back down." :)
this is what i was recommending my Wildfire Season mod for, to tune down the fire hop limit, which is how far a fire can spread from the first tree that burned. you can set it to 1 or 2, and that will make fires less devastating with high tree count.
We were having entire screen fulls of forest on fire at once. Did WONDERS for the pollution map, heh.