Better Air Filtering

by JoeyDP

An overhaul of the air filtering mod by Schorty. Includes complex air filtering steps to remove pollution.

Content
3 years ago
0.17 - 1.1
10.3K
Environment

i [Implemented] UPS

3 years ago

I put about 100 machines with modules scattered across my large factory, and it is reducing the amount of pollution nicely. Thanks!

However, this number of machines is using about 1ms per tick. I was looking at the mod's code to see if anything in particular looked like it could be optimized, and one thing that stood out to me is the suction effect. It's doing a lot of creation (and presumably garbage collection) of objects. One thing that occurs to me is that the game engine itself already spreads pollution from a chunk with more pollution to a chunk with less pollution. Perhaps a similar way to get the same effect would be to have the filters mk2 and mk3 consume pollution from surrounding chunks, rather than having them redistribute the pollution closer to the filter. The game would then spread pollution from further away, accomplishing the same thing as the current design but with less of a UPS hit.

If this sounds like a good plan, I can work on a pull request.

3 years ago

I don't quite remember how I implemented this mechanic exactly. Depending on the details, you may not be able to achieve much benefit from your suggestion, since the same amount of chunks need to be scanned and updated. If you still want to implement it, feel free to have a go at it. However, I will only merge it if you can prove a big enough performance gain while the effect of the mod stays the same.

Have you already tried the update interval setting for my mod? I would be interested to know whether changing this helps out enough to make it usable in large bases.

–Joey

3 years ago

As a proof of concept, if you turn off the suction entirely, the maximum time usage goes down to about 1/10th. Obviously turning off the suction is changing the mechanism of the mod, which I know you don't want to do, so I'll try to come up with a changelist that respects what the mod is doing while still using a bit less UPS.

3 years ago

I ran what I described for about an hour, and it wound up putting holes in the pollution cloud above the filters, lowering the filter's effectiveness. Apparently the pollution dispersion built into the game isn't quick enough to accommodate that much scrubbing. I can think of some ways to try to compensate for that, but in the meantime I went with the alternate approach of trying to optimize the function a bit. Fewer object creations and fewer table creations. Overall it speeds things up about 25%. I'll send a pull request

3 years ago

Merged in 0.3.3. Thank you for the optimizations!

–Joey

3 years ago

Thanks for the quick turnaround and the acknowledgement!

New response