-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimise HourlyFactoryUpdate() #12
Comments
Possible culprit: calling into lua (strategicmap.lua, GetFactoryLeftoverProgress()) way too many times. |
Most of the time seems to be spent on line 13671 Now, I don't know how lua scripting is supposed to work, but having to read and evaluate scripts/strategicmap.lua from disk on every function call seems silly. Surely there should be a way to cache that, no? Edit: maybe something like this? I don't know the workings of factories and the lua code enough to say if there are no unintended consequences, but it gets rid of the constant disk access and hickups
|
If I understood the code correctly, this should be okay. Moved the IniGlobalGameSetting out of initialization block as it sets global stuff for the LuaScopeState that can change upon starting a new game / loading a save
|
Reopening this as my previous solution had to be reverted. See issue #292 SetFactoryLeftoverProgress was still working correctly, even though it used similar caching of reading and evaluating strategicmap.lua file before the function call.. |
I've noticed that enabling factories causes a long and very noticeable delay whenever the hour ticks over. After stepping through HandleHourlyUpdate(), the biggest offender by far is this factory function - almost every other hourly update takes 1-2ms, with one or two approaching 10ms, but the HourlyFactoryUpdate() usually takes a whopping 500ms on my machine, even with no items in production.
The text was updated successfully, but these errors were encountered: