Slow saves and loads

@Olof I’ve noticed you’re using JSON serialization for saving the game state, which, while it’s typically fine for most unity games, in your case you are saving a lot of data.

On even small airports the save data can be over 30MB, with the GameData.json file being the largest (~70%).
This leads to hitches while loading/saving that cause serialization/deserialization to take 600-1500ms which is fairly noticeable especially when autosave is on with the fastest speed.

On larger airports, I’ve noticed this time go to the 2-3sec range which can be really distracting for the player.

From my own experience as a professional C# web developer, I can tell you that JSON is not a good choice when you need high throughput and when dealing with very large data structures.

Personally, I would recommend using FlatBuffers: FlatBuffers though it would probably be best to benchmark for your case.
Something like this would not only lead to a significant reduction in file size but also a significant speedup in serialization/deserialization. Just the lower file size itself will bring an improvement in the duration to read it.

Let me know what you think about this.

4 Likes