Saving and loading a game takes a long time - Dev explains.

Ask here if you experience technical problems with X4: Foundations.

Moderator: Moderators for English X Forum

enigma_dt
Posts: 2
Joined: Fri, 4. Feb 05, 13:10
x4

Saving and loading a game takes a long time - Dev explains.

Post by enigma_dt »

Hi guys I hope this is the right place for this topic.
I haven't found anything about this in the forum via the search.

I've been playing X4 since day 1 and it's still the first game start. Currently as I write this post I am playing X4 version 7.00.
I have all the expansions and also hundreds if not a few thousand of my own ships. Of course I also have my own sectors with my own shipyards and many space stations.
I play the vanilla version without scripts and mods.

Loading and or saving a savegame takes a long time.
Without knowing more about the engine, I guess that the long loading time of the savegames is due to the xml structure.
The bigger the universe you play in, the longer the loading time.

Maybe it is possible to save the savegames in a binary format. Instead of xml you could use protocol buffers. This would allow you to serialize and deserialize data very quickly.
Before the moderators get on my case, you can make this way of saving optional.
Unfortunately I know too little about the engine and modding to judge how much such a change would interfere with the program code.

Maybe a modder or an Egosoft employee sees this and we can argue a little about the loading times of the savegames.

I would be happy if saving and loading would be faster.

Best regards,

someone who has locked the Xenon as pets in his universe in a single sector. :mrgreen:
CBJ
EGOSOFT
EGOSOFT
Posts: 54162
Joined: Tue, 29. Apr 03, 00:56
x4

Re: Saving and loading a game takes a long time

Post by CBJ »

Loading and saving takes a long time because the game universe is huge and contains thousands of objects. The file format has nothing to do with it, because the process is threaded so that the serialisation and deserialisation is done in parallel to other parts of the process.

You already have the option to choose between the standard, compressed file format and the uncompressed one. Again, because of threading, there is no time disadvantage to using the compressed format, and indeed it's actually usually faster because of the decreased file size. Compression effectively makes the file format binary, at least in terms of size and time to read from the drive, so we recommend people leave it enabled.

You may get a small advantage from making sure that your personal folder is on an SSD drive rather than an HDD, but most of the time taken to save is spent extracting all the information that needs to be saved from the game universe, and the vast majority of the time taken to load is spent recreating that universe. Note that simplistic solutions that may have worked for simple games 30 years ago, like dumping memory to the drive, don't work with modern, complex games that don't just have a linear chunk of memory that contains all their data.

To cut a long story short, we too would be delighted if we could make saving and loading faster, but we have optimised the living daylights out of the process, and the only thing left that would make it faster would be not having such a big universe!
enigma_dt
Posts: 2
Joined: Fri, 4. Feb 05, 13:10
x4

Re: Saving and loading a game takes a long time - Dev explains.

Post by enigma_dt »

Thank you for your quick reply and the detail. I did not expect that.

I am surprised that parsing and writing the xml file is not the bottleneck as there is a lot of overhead in such a file that a program does not need.

I couldn't imagine that extracting thousands of objects from the "universe" would take a long time, because in my imagination everything is in ram and you "only" have to save the information of the objects. Now that I think about it, I realize that there must be tens of thousands of objects, since there are objects that in turn have several objects.

You can probably only get around this by constantly writing every change of state somewhere in order to save it away. But building that is probably far too time-consuming and instead of wasting resources on it you could build 5 other cool things.

I already know about compressing the savegame. That's also necessary with my savegame because I've simply built too much. 😆

I find it interesting that you can't just save a memory dump and nowadays you have to go other ways to save a savegame.
I would like to understand it more but unfortunately I am not familiar with it.

I can live with the statement that you have optimized it down to the last detail. 👍
It's a great game and I'm having fun with it.
dziks
Posts: 3
Joined: Wed, 2. May 07, 11:48

Re: Saving and loading a game takes a long time - Dev explains.

Post by dziks »

The long load time is frustrating, and if it cannot be speeded up for the app, could you perhaps make it shorter for the player? For example, loading the "paused" game so that a player can start browsing through missions, owned stations, ships, while the rest of the wonderful and complex X4 universe is recreated in the background. I know we might save a minute or two, but multiply that by the hundreds of times we, the funs, start this game and it would make a difference.
CBJ
EGOSOFT
EGOSOFT
Posts: 54162
Joined: Tue, 29. Apr 03, 00:56
x4

Re: Saving and loading a game takes a long time - Dev explains.

Post by CBJ »

No, I'm afraid that doesn't work. Your property is part of the universe, so you can't start browsing through it until it's been loaded!

Now, this is not a Tech Support discussion and this thread is from last year anyway, so let's not dig it up again please. :)

Return to “X4: Foundations - Technical Support”