Page 2 of 2
Re: Shortening the Saving time?
Posted: Wed Sep 16, 2015 12:32 pm
by Tony Li
Thanks! I'll focus on optimizing SimStatus, since that accounts for almost half the slowness, and look for other areas to optimize, too. Approximately how many GameObjects do your scenes have? Hundreds? Thousands? Tens of thousands?
Re: Shortening the Saving time?
Posted: Wed Sep 16, 2015 8:22 pm
by Tony Li
I'm sorry to ask, but would you mind testing a scene that has a very small number of GameObjects? Please use the same dialogue database asset so it saves the same SimStatus values. My closest test platform is an iPad 2, and I'm trying to narrow down what's causing the slowness on your iPhone 6. One possibility is sending "OnRecordPersistentData" to all of the GameObjects in the scene to give them a chance to save their data. In my testing, this hasn't been a source of slowness. But I want to make sure it's the same case for your iPhone 6. Thanks!
Re: Shortening the Saving time?
Posted: Wed Sep 16, 2015 11:38 pm
by danthepob
Hello,
I tested a scene with over a hundred objects and one scene with less than twenty, and there doesn't seem to be a difference in the time it spends on saving.
Re: Shortening the Saving time?
Posted: Wed Sep 16, 2015 11:53 pm
by Tony Li
Thanks for checking that. I tested a scene with 10,000 GameObjects and found the same thing.
Do any of your GameObjects have custom persistent data components?
Is there any possibility you could email your dialogue database to me at tony (at) pixelcrushers.com? (All customer data/projects are treated confidentially.) I'll see if I can identify where it's spending the most time.
Would it help if I added an asynchronous version of GetSaveData()? This would allow the game to keep running while it gathers save data, but your bit of code would be a little more complicated. If you currently save your game similar to this:
Code: Select all
void SaveGame() {
PlayerPrefs.SetString("save", PersistentDataManager.GetSaveData());
}
you would have to instead save it like this:
Code: Select all
IEnumerator SaveGame() {
var asyncSaveData = PersistentDataManager.GetSaveDataAsync();
while (!asyncSaveData.isDone) {
yield return null;
}
PlayerPrefs.SetString("save", asyncSaveData.content);
}
(I'm finishing up work for the day, but I'll check back first thing in the morning.)
Re: Shortening the Saving time?
Posted: Thu Sep 17, 2015 12:17 am
by danthepob
Hi,
Nope, I don't have any custom persistent data components. Oh and sorry, I don't think I can send you my database since my author requested not to distribute his contents out in any way until the project's released. However, from what you posted, the asynchronous version of GetSaveData() does sound wonderful and easy to implement. Thanks!
Re: Shortening the Saving time?
Posted: Thu Sep 17, 2015 9:50 am
by Tony Li
Hi,
Not a problem! I'll send you the patch later today.
In the meantime, here's something else you could try if you want:
1. Make a copy of your project.
2. Open the copy, and import Assets/Dialogue System/Third Party Support/NLua Unity 5 Support.unitypackage.
3. Test save/load speed.
The steps above will switch Lua implementations from LuaInterpreter to NLua. NLua is written in C++. It's faster when processing a lot of Lua code. In regular Dialogue System use, it doesn't provide a noticeable speedup because the Dialogue System uses Lua so minimally. In my tests, it also made no difference in saved game speed because most of the time is spent crossing the Lua / C# border to extract the save data. But it's possible that it might shave off a little time on your iPhone 6.
Re: Shortening the Saving time?
Posted: Thu Sep 17, 2015 11:08 pm
by Tony Li
Okay, Patch 2015-09-17 is available on the customer download page now. The code to use the async version is the same as above.
There are two variables you can tweak also:
- PersistentDataManager.asyncGameObjectBatchSize (default 1000): How many scene GameObjects are sent "OnRecordPersistent" each frame.
- PersistentDataManager.asyncDialogueEntryBatchSize (default 100): How many dialogue entries' SimStatus values are recorded each frame.
Re: Shortening the Saving time?
Posted: Fri Sep 18, 2015 12:52 am
by danthepob
Hi Tony,
I just implemented this and it works great! No more hiccups and freezes in the game while saving. The turnaround time for this issue has been great, really thank you for the support!
Oh and for completion, I did the test with NLua and didn't find any noticeable difference in performance.
Thanks again!
Re: Shortening the Saving time?
Posted: Fri Sep 18, 2015 10:21 am
by Tony Li
Hi,
Great! I'm glad it's working. Please feel free to post a link to your game if you want. I'm always interested in what people are doing with the Dialogue System.