it's kinda insane that replacing all settings.{storage,global} calls with storage[] calls got me down to 0.070 ups from 0.090. (with 4 running reactors)
wouldnt heavy use of the storage table be terrible for the network load?
attached a modified version (based on 2.0.15) of the mod utilizing the storage table.
note that this version will be incompatible with future and previous updates. it's just for performance comparisons
it's meant to overwrite the mod mid-game
make settings calls more performant
make settings calls more performant
- Attachments
-
- RealisticReactorsReborn_2.0.15.zip
- (18.71 MiB) Downloaded 11 times
Last edited by ownlyme on Sat Dec 28, 2024 3:07 pm, edited 7 times in total.
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Re: make settings calls more performant
Indexing has a cost in lua. If you have a lot of things like settings.global.thing in your code, consider extracting that into a local variable and then using that.
Re: make settings calls more performant
this is more than the indexing cost though. they are still in a 2d table
if i add another dimension with {value = ...}, it does cost another 0.007 ups indeed (still less than using settings... calls)
that third dimension isn't used at all though, maybe they can save some performance by cutting that?
https://lua-api.factorio.com/latest/con ... tting.html
if i add another dimension with {value = ...}, it does cost another 0.007 ups indeed (still less than using settings... calls)
that third dimension isn't used at all though, maybe they can save some performance by cutting that?
https://lua-api.factorio.com/latest/con ... tting.html
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Re: make settings calls more performant
Lua doesn't have "2d tables", there are only tables of tables, that is lua Values that hold pointers to garbage collectable objects. There's some magic so that tables with number indices behave like arrays, but generally they're all hashmaps.
You found how to make your mod faster, so you can implement that.
[edit]
So the settings returns a custom lua table-like object that has lazy evaluation. Probably shouldn't be too different performance wise aside from not loading the whole thing at once.
You found how to make your mod faster, so you can implement that.
[edit]
So the settings returns a custom lua table-like object that has lazy evaluation. Probably shouldn't be too different performance wise aside from not loading the whole thing at once.
Last edited by GTG3000 on Sat Dec 28, 2024 2:39 am, edited 1 time in total.
Re: make settings calls more performant
did i find a way to make it faster? or did i find a way to make it unplayable in multiplayer? idk, i dont play this game in mp
also no clue why you don't want settings to be more performant and defending the current implementation
i'd prefer to not make my code less maintainable and update all my 52 mods to have a smaller performance hit for no reason if the devs could just flip a switch and everyone gains 20% free performance
if i had to remove the .value code snippet everywhere because they changed the way settings work, that would be okay though
also no clue why you don't want settings to be more performant and defending the current implementation
i'd prefer to not make my code less maintainable and update all my 52 mods to have a smaller performance hit for no reason if the devs could just flip a switch and everyone gains 20% free performance
if i had to remove the .value code snippet everywhere because they changed the way settings work, that would be okay though
Last edited by ownlyme on Sat Dec 28, 2024 2:46 am, edited 2 times in total.
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Re: make settings calls more performant
So long as you're putting stuff into storage, it should be fine. There's desyncs when a function changes a variable outside of it's scope, not when stuff is accessed in storage.
I've seen someone talk about this recently on the 2+2=fish reddit thread
I've seen someone talk about this recently on the 2+2=fish reddit thread
Re: make settings calls more performant
i just tried putting everything in _G instead of storage.s (replacing most stuff to even access it without a _G[" prefix) and it did nothing for the performance, so indexing doesn't seem to cost much
(yes it took me almost an hour to test this)
still think devs should take a look at settings performance
(yes it took me almost an hour to test this)
still think devs should take a look at settings performance
Last edited by ownlyme on Sat Dec 28, 2024 8:46 pm, edited 1 time in total.
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Re: make settings calls more performant
It's all API calls and new LuaObjects being allocated. What else did you expect? If you can't bear the cost, cache it.