Optimizing LuaWatchers.NotifyObserver() taking 450+ ms
Posted: Sat Aug 03, 2024 7:25 am
[Unity 2021.3.38f1 - DS v2.2.46.1 - AC v1.81.4 - Articy v2]
Hi Tony,
I've been experiencing some hiccups (1-2s on my machine) while saving during our game and, looking into the Profiler with Deep Profile activated, I noticed that there are a lot of LuaWatchItem.Check() under LuaWatchers.NotifyObserver() as per the following screenshots:
Now:
It currently seems not too much of a big deal when manually saving, but it is an issue during autosaves, that we would like to happen in a more "silent" way.
My guess (and I could be wrong), by looking at the profiler in Deep Profile mode, is that that anytime a Lua variable is updated, all of them are being checked via observation, and that of course, happens during saves.
For the sake of completion, I have asked a similar question on the AC's forums, as 50% of the hiccups are currently also generated by having enabled screenshots to save games.
When I write that I'm worried about opening "a can of worms" when I realized roughly the same time was taken by DS, know that I'm referring to having to radically change something in how we deal with game logic and variables, so it's not a commentary on DS itself!
Thanks a lot, as always!
Hi Tony,
I've been experiencing some hiccups (1-2s on my machine) while saving during our game and, looking into the Profiler with Deep Profile activated, I noticed that there are a lot of LuaWatchItem.Check() under LuaWatchers.NotifyObserver() as per the following screenshots:
Now:
- I understand this is not strictly related to saves, since I do rely a lot on observing Lua variables (the majority of the logic is intertwined with our use of Articy)
- I know that string checking is an expensive operation, especially on a scale this large.
It currently seems not too much of a big deal when manually saving, but it is an issue during autosaves, that we would like to happen in a more "silent" way.
My guess (and I could be wrong), by looking at the profiler in Deep Profile mode, is that that anytime a Lua variable is updated, all of them are being checked via observation, and that of course, happens during saves.
For the sake of completion, I have asked a similar question on the AC's forums, as 50% of the hiccups are currently also generated by having enabled screenshots to save games.
When I write that I'm worried about opening "a can of worms" when I realized roughly the same time was taken by DS, know that I'm referring to having to radically change something in how we deal with game logic and variables, so it's not a commentary on DS itself!
Thanks a lot, as always!