Bottleneck

by trold

A tool for locating input starved machines.

Utilities
30 days ago
0.13 - 2.0
257K

g perf

4 years ago

The default settings require ~0.6ms on my pc and it gets very unresponsive with a bigger factory.
Looking quickly at the code I don't see any state being stored apart from the signal being displayed.
Would it be possible to use https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.find_entities and process just the machines currently being rendered?

4 years ago

If possible, this would have an additional benefit of having simpler logic, no events would need tracking, and it would be completely stateless.

4 years ago

I tried to do this with the 0.17 rendering API which allowed spirtes to be only rendered for a player, in addition you could also toggle the display on a per player basis. Unfortunately the sprite system could not handle the amount of sprites needed for the mod. (Reference: https://github.com/troelsbjerre/Bottleneck/pull/53 and https://forums.factorio.com/viewtopic.php?f=28&t=69230).
Due to this we are once again stuck with rendering entities which are on a per faction basis and have (to my limited understanding) a high cost related to creating/destroying.
Which is a long way of saying I couldn't get it to work and get a better performance than what we have.

Have you tried the latest version of the mod which should have significantly improved performance as it uses the in game status for tracking (easier on the performance than checking ourselves).
If you could send me a link to save game I could try to look into what's eating the most performance.

4 years ago

Thanks for the response.
Last version I used was 0.10.4. I don't want to bother you with specific saves, all have the same time cost once there's enough entities for a single update to do max specified in the settings.

4 years ago
(updated 4 years ago)

Okay, i did some testing on it. (still 0.17 version. My efforts may be completely unwarranted in 0.18 version but I wanted to try it anyway). I have mixed results.
I tried a simple script that queries all machines in the player visible range (is there a way to get zoom? I had to use lowest zoom value) and draws a rectangle with color based on entity's status. Also the way i've written it is terrible for multiplayer, and I'm not sure if anything can be done about that.
https://pastebin.com/KN9NmxL9

I tested with 2304 furnaces (9 full chunks) in a creative world (otherwise empty). Curiously bottleneck takes about half the time for an update compared to a real world (hovering around 0.3ms).
My approach has, as expected, quite bad performance in areas with a lot of machines. When all 2304 furnaces are visible one update costs ~40ms, so ~0.7ms amortized per frame (around 2-3 times that of bottleneck in this particular world). It would require some clever work splitting to prevent lost frames.
When no entities are in player's view the script takes negligible ~0.004ms. Whereas bottleneck has a constant overhead.

I will maybe try to do some tests on a real save later.

4 years ago

Thanks for putting in the work, but if you are still on 0.17 you are using the old bottleneck version wich had a lot more overhead.
Only versions from 0.11.0 have the new logic and they are only compatible with 0.18.
So thanks again for all the work, but may I suggest testing the latest optimized version first, or at leas comparing against it?

4 years ago
(updated 4 years ago)

Yes, I will before pursuing this further.

New response