[Optimization] Lamp performance improvement

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
buggy123
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Sat May 13, 2017 11:53 pm
Contact:

[Optimization] Lamp performance improvement

Post by buggy123 »

TL;DR
Lamp optimization; change them to work entirely like solar panels to further reduce their performance impact, adjust visuals slightly to accomodate.



Note: This suggestion applies to normal, non-circuited lamps only. Circuited lamps can't be optimized as I am about to suggest and should remain as-is.


Why, aren't lamps already optimized ?
Yes; A few years ago, lamps got optimized as described in Friday Facts #229. This was a good change which made lamps much more performant.

Unfortunately, there is still a little performance impact. It's small, but the electric network updates can still add up when lamps are turning on/off:
Image

140,000 lamps is quite a lot. But real factories can still use enough lamps to cause noticeable lag. As a example, here's the # of lamps on a MP server where they're used only sparingly:
Image
With more consistent usage, there could be tens of thousands or more.

Given this, I think that investing a bit more effort to further optimize them would be a good idea.

How? They're already optimized very well.
As is, yes, they can't really be improved further without creating a disconnect between visuals and gameplay. If you remove the connection between visual appearance and the actual power consumption, a observant player would notice the discrepancy while watching the power graph at nightfall. This would be a problem even if you made the power consumption gradually increase or similar.

And it wouldn't be good to remove the staggered lighting-up of the lamps, because it looks quite nice.

But there's a third option: change the visual appearance a little.
Image

Instead of instant-on, instant-off, give them a visual warm-up period. This should probably still be staggered so groups of lights have more visual distinctiveness.

With a warm-up period, it's much less obvious that the lamp isn't perfectly synchronized with it's power consumption. This allows it to be switched over to solar panel-like consumption:
Image
And done! Zero UPS-impact lamps! Safe to pave a factory with.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: [Optimization] Lamp performance improvement

Post by ssilk »

The problem is, that every lamp needs to be “turned on”. Because every lamp is an extra power consumer. There is no general switch for them. They have optimized that, but for 100.000 lamps, each lamp needs to be turned on/off.

But your suggestion is maybe a way to solve this problem.

Hm. Eventually you can post your map to viewtopic.php?f=5&t=17501
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2247
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [Optimization] Lamp performance improvement

Post by boskid »

There are no reasons to change current lamp staggering behavior in order to optimize this logic. Electric network right now has a vector that maps from a UnitNumber into a staggeringModifier of a lamp. Currently this code has a linear complexity O(N) while lamps are turning on because electric network has to scan this entire vector to count how many elements fulfill the staggering value condition. There are some possibilities to rewrite this code to have a vector of staggering modifiers in a non-descending order that would allow counting how many lamps are turned on using a binary search reducing time complexity down to O(log N). In the end this logic only needs to produce one number: how many lamps are to be reported as consuming energy in current tick (using current surface's daytime).

Post Reply

Return to “Ideas and Suggestions”