ReikaKalseki / Reika_FactorioMods_Issues

The issue tracker for all of my Factorio mods - EndgameCombat, NauvisDay, Geothermal, Oreverhaul, and the rest.
5 stars 1 forks source link

[Suggestion] Geothermal: Handle cooling thermal water also in tank #326

Open DarkShadow44 opened 3 years ago

DarkShadow44 commented 3 years ago

Right now the thermally heated water loses heat when put into normal fluid wagons. Maybe something similarfor storage in fluid tanks is possible?

ReikaKalseki commented 3 years ago

This is an idea I like in principle, but it is not really implementable - tanks exist in too large a number across a map to make caching their locations and ticking them remotely performant.

DarkShadow44 commented 3 years ago

Hm, wouldn't ticking every 5 seconds or so be good enough, for performance I mean? For clarity, only the ticking is performance relevant, right? As a fallback, for too many tanks, maybe distribute the ticks randomly over a limited number of tanks? That would delay the effect a bit, bit would keep the performance high.

ReikaKalseki commented 3 years ago

Hm, wouldn't ticking every 5 seconds or so be good enough, for performance I mean?

No, because the sheer size of that cache would make just storing and reading it expensive, plus the fact that factorio lends itself to massive spam of infrastructure where hundreds of thousands of tanks is not an unrealistic expectation.

As it is, I have issues with people complaining about EndgameCombat because they use ten thousand custom-scripted turrets.

DarkShadow44 commented 3 years ago

I understand.. From a design perspective, would preventing the fluid from entering a tank be good enough? There's already a filter property for pipes/tanks, maybe they are willing to add a blacklist filter as well?

DarkShadow44 commented 3 years ago

So, I researched a bit, and I don't think a blacklist filter will be coming (devs said it would need a big rework since the fluid system doesn't work like that).

However, we could only update a certain number of tanks - I got a small POC (for steam). The idea is:

I tested with ~370k tanks. With that mod, I get 48 UPS, without 56 UPS. Which sounds acceptable to me.

Test save (370k tanks): testtanks.zip

For a few tanks only, you can always make a fresh save.

POC mod: SteamCooling_0.0.2.zip (Adapted from https://mods.factorio.com/mod/SteamCooling)

What would you think about that idea?

ReikaKalseki commented 3 years ago

1000 tanks a tick is still going to be massively overly costly, and that does not avoid the need to cache every tank in a giant global table whose size would probably double save/load times.

DarkShadow44 commented 3 years ago

1000 tanks a tick is still going to be massively overly costly

Yeah, that's the problem with handling the concept in lua. Sure it loops 1000 times, but keep in mind that most tanks are paused from ticking for 5-10 ticks before they get considered again. What drop in performance would you consider acceptable? As I said, I tested, and the drop wasn't too bad with 370k tanks.

and that does not avoid the need to cache every tank in a giant global table whose size would probably double save/load times

The table could be recreated every load. This should still be faster for loading, and a lot for saving.

ReikaKalseki commented 2 years ago

The table could be recreated every load.

This requires scanning the surface, which is very slow - making loading even slower - and creates a huge RAM spike on large maps.