Performance issues with GetSaveDataAsync()

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Liktoria
Posts: 3
Joined: Mon Nov 15, 2021 10:21 am

Performance issues with GetSaveDataAsync()

Post by Liktoria »

Hello!
We are working with the Dialogue System (Version 2.2.0) in a bigger project and are experiencing some performance issues with the PersistantObjectManager.GetSaveDataAsync() (using this implementation: https://www.pixelcrushers.com/dialogue_ ... nager.html). These performance problems are only notable on the Nintendo Switch and not on a PC. There is a significant lag when using the function on the Switch. First it was implemented using the GetSaveData() function, which also caused performance problems. Unfortunately switching to the GetSaveDataAsync() function didn't solve the issue. To make sure nothing else is causing this, I singled out the function and called it specifically on a button press. This is the implementation:

Code: Select all

private IEnumerator GetSaveData()
        {
            Debug.Log("Starting async operation.");
            var asyncOp = PersistentDataManager.GetSaveDataAsync();
            while (!asyncOp.isDone)
            {
                Debug.Log("Working on async operation.");
                yield return ;
            }
            string mySaveData = asyncOp.content;
            Debug.Log("Async operation finished.");
        }
Adding debug logs showed that the operation is executing over a few frames ("Working on async operation" is printed 6 times), but it still seems to be too much to handle for the Switch. Increasing or decreasing the asyncDialogueEntryBatchSize didn't change the performance. Sim status is not included in saving. These are Unity's deep profiling results on the Nintendo Switch:
2021-11-15 16_36_06-.png
2021-11-15 16_36_06-.png (145.55 KiB) Viewed 220 times
Do you have any suggestions for this? Thanks in advance!
Liktoria
Posts: 3
Joined: Mon Nov 15, 2021 10:21 am

Re: Performance issues with GetSaveDataAsync()

Post by Liktoria »

A little update: I upgraded to the most recent version of the Dialogue System to see if that would fix the issue, but it actually made the lag even more significant. Now it is also noticitable in the editor which wasn't the case before. This time the function AppendItemData() seems to be causing the overhead, while in the ealier version AppendActorData() was using a lot of resources. This is a screenshot of the deep profile when playing in the editor:
2021-11-16 12_24_42-.png
2021-11-16 12_24_42-.png (89.86 KiB) Viewed 218 times
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Performance issues with GetSaveDataAsync()

Post by Tony Li »

Hi,

Try switching to GetRawData(). It generates a larger save file, but it's much faster. It's what large games like Disco Elysium use on all platforms, including Switch.

There's also a patch that optimizes AppendItemData(). It's not used by GetRawData(), but it's used by the regular GetSaveData().

DS_PersistentDataManagerPatch_2021-10-30.unitypackage
Liktoria
Posts: 3
Joined: Mon Nov 15, 2021 10:21 am

Re: Performance issues with GetSaveDataAsync()

Post by Liktoria »

Thanks a lot Tony! I switched to GetRawData() now, which did increase the performance of the game. Unfortunately there was still a significant lag, so I moved this process to another thread after a few adjustments. That works quite well and there are no more lags. Thanks again for your help!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Performance issues with GetSaveDataAsync()

Post by Tony Li »

Glad to help!
Post Reply