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

Place to get help with not working mods / modding interface.
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

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

Post 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?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5290
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

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

Post by Klonan »

I think the log file will show the timing for calculating the CRCs, maybe with verbose logging enabled
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

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

Post 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?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5290
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

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

Post by Klonan »

Can you provide a log and a save game?
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

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

Post by BiterUnion »

Sure, thanks for your help.
Last edited by BiterUnion on Sat Feb 04, 2023 6:02 pm, edited 1 time in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14363
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

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

Post 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!
Post Reply

Return to “Modding help”