Reduce overhead of LuaEntity::get_signals with parameter if_modified_since

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Harag
Inserter
Inserter
Posts: 31
Joined: Sun Sep 30, 2018 9:49 am
Contact:

Reduce overhead of LuaEntity::get_signals with parameter if_modified_since

Post by Harag »

I'd like to propose the following signature change to LuaEntity::get_signals():

Code: Select all

get_signals(wire_connector_id, extra_wire_connector_id?, if_modified_since?) → array[Signal]?, MapTick
Read all signals from the selected wire connector.

Parameters

wire_connector_id :: <as before>
extra_wire_connector_id :: <as before>
if_modified_since :: MapTick? only return fresh signals if they were modified after this tick

Return values
→ array[Signal]? Current values of all signals, nil if there are no signals or if there were no modifications
→ MapTick the tick the signals were last modified, less than or equal to if_modified_since if there were no modifications
With this mods like LTN and Cybersyn that frequently poll signals could greatly reduce Lua garbage overhead and subsequent recalculations for idle circuit networks.
I assume this information is already present somewhere because combinators know when to recalculate, too.

If this is added, there should probably also be a property LuaCircuitNetwork::last_modified : MapTick.

My guess is adding the same to LuaEntity::get_signal() would not be a big improvement. That function already returns an int, only.
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 503
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: Reduce overhead of LuaEntity::get_signals with parameter if_modified_since

Post by Stringweasel »

+1

Related: 98542
Alt-F4 Author | Factorio Modder
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration
The_LORD_thy_GOD
Inserter
Inserter
Posts: 22
Joined: Sun Nov 10, 2024 5:23 pm
Contact:

Re: Reduce overhead of LuaEntity::get_signals with parameter if_modified_since

Post by The_LORD_thy_GOD »

Seconded. This could save considerably Lua time in any mod that uses combinators for gathering input.
Post Reply

Return to “Modding interface requests”