How can I optimize Lua.IsTrue() on Update()?
Posted: Thu Jul 22, 2021 8:47 am
Disclaimer: I am still a beginner at profiling code, so pardon me if I say anything stupid xD
Our game is suffering from intermittent freezes every other couple of seconds. After taking a look at the CPU Profiler and the Call Stack, blocks of GC.Alloc() and GC.Collect() caused by Lua.IsTrue(string) seem like the "culprit".
The game relies on checking for many Lua conditions several times per frame, and the way I do it currently is calling Lua.IsTrue(condition) every time I need to check the value of condition.
I created some sort of manager to limit the number of calls to this function per frame since many of those aren't frame-critic, and I did reduce the number of calls per frame from +20 to 5 (a value chosen by me), but it still keeps causing freezes.
How can I keep checking for Lua conditions while avoiding the freezes?
Our game is suffering from intermittent freezes every other couple of seconds. After taking a look at the CPU Profiler and the Call Stack, blocks of GC.Alloc() and GC.Collect() caused by Lua.IsTrue(string) seem like the "culprit".
Screenshots
I created some sort of manager to limit the number of calls to this function per frame since many of those aren't frame-critic, and I did reduce the number of calls per frame from +20 to 5 (a value chosen by me), but it still keeps causing freezes.
How can I keep checking for Lua conditions while avoiding the freezes?