Page 1 of 1

"Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 3:11 pm
by BiterUnion
I am currently writing a mod and have noticed that the "Checksum for script __my_mod__/control.lua" step takes longer than usual. It used to be almost instant, but now takes 3-4 seconds and is noticable when loading a savegame for example.

Is there any way to get more info about what is taking so long, maybe like a hotspot analysis?

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 4:03 pm
by Klonan
I think the log file will show the timing for calculating the CRCs, maybe with verbose logging enabled

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 4:15 pm
by BiterUnion
Thanks for the quick reply!

I am pretty sure calculating the CRCs is what is taking so long, so I was hoping there was a way to find out exactly what part of the calculation takes up most of the time. Unfortunately verbose logging does not output that.

Could you maybe give me one or two pointers what the CRC is actually calculated for? Is it a CRC for the Lua code only or also the global data? In other words, should I look into reducing code size (although I don't have particularly much code) or global data (also not that much), or cross references in global data, or something else to speedup CRC calculation?

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 4:25 pm
by Klonan
Can you provide a log and a save game?

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 4:49 pm
by BiterUnion
Sure, thanks for your help.

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 5:51 pm
by Rseding91
The crc calculation is essentially instant. All of the time is spent in the function call to the results of requiring "__testorio__.init"

This part:

Code: Select all

{
  'tests.core.Class', 'tests.core.Error', 'tests.core.Helper', 'tests.core.List', 'tests.core.Callback',

  'tests.events.EventHandler',

  'tests.gui.Component', 'tests.gui.WindowManager',
  'tests.gui.factorio.FactorioComponent'
}
Specifically almost all of the time is spent making and populating lua tables.

I'm not sure what the testorio mod aims to do; but it looks like it will likely have issues due to it overwriting the 'require' function which factorio itself already overwrites and implements differently.

Re: "Checksum for script __my_mod__/control.lua" suddenly takes longer

Posted: Sat Feb 04, 2023 6:02 pm
by BiterUnion
I use testorio for unit testing. But if it is only the testing that takes time, then that's not an issue.

Many thanks again!