Optimize idle circuit networks

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
Teraka
Inserter
Inserter
Posts: 34
Joined: Mon Jun 27, 2016 7:50 pm
Contact:

Optimize idle circuit networks

Post by Teraka »

When an entity is connected to the circuit network, it checks for the network's state every tick. This is fine for smaller combinator builds, but starts being a big UPS drain when connecting lots of entities to networks, especially with lamps displays and similar designs. In a lot of situations, those networks will stay idle on most ticks, meaning a lot of entity updates could be skipped.

Here's a test world with nothing except 6.4k lamps connected in pairs with the condition "everything = 0" (i.e. always active)
Image

Despite the networks being completely idle, the setup still uses up 0.5ms on my mid-range PC.

I don't know how the circuit networks functions on the code side, and I know this would be a low priority change at best, but I'd like to suggest a change in how entities read the state from the circuit network:

If the network's state doesn't change from tick to tick, then the state of all the reading entities won't change either. Which means that you can have reading entities sleep, and have the network wake up connected entities when its state changes. This way, only the network needs to be checked for updates every tick rather than each entity.

Hannu
Filter Inserter
Filter Inserter
Posts: 850
Joined: Thu Apr 28, 2016 6:27 am
Contact:

Re: Optimize idle circuit networks

Post by Hannu »

This seems to be quite extreme problem. Based on your experiment you can have order of ten thousand idle entities connected to circuits without significant hit on performance (which tells about already very well optimized code). I do not see any real situation in the "normal" games where this would be a problem. And I think that special needs for those who make microprocessors etc. strange stuff may not be on top of dev's work lists at this point of development. I am certain that developer's work hour used to optimize something else would give much more UPS benefit to 99.99 % players.

Teraka
Inserter
Inserter
Posts: 34
Joined: Mon Jun 27, 2016 7:50 pm
Contact:

Re: Optimize idle circuit networks

Post by Teraka »

As I said, I expect this to be a low-priority fix at best.

However, it can impact actual bases in some cases. My WIP megabase uses lamps to show incoming trains, with a total of over 9k lamps so far in the network. Even when the factory is running, the lamps alone use up more than 1/3rd of my update time, which is very non-negligible.

Image

Post Reply

Return to “Ideas and Suggestions”