Savegame technical suggestions

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
quinor
Filter Inserter
Filter Inserter
Posts: 404
Joined: Thu Mar 07, 2013 3:07 pm
Contact:

Savegame technical suggestions

Post by quinor »

Discission on IRC has lead us to some ideas about optimising game saving and autosaves:

1) Use copy-on-write to "duplicate" game state and then use this copy while saving (on another thread); it may enable autosaves without pausing the game

2) Add "disable replay" option in order to lower savegame size

I hope it helps.

hoho
Filter Inserter
Filter Inserter
Posts: 677
Joined: Sat Jan 18, 2014 11:23 am
Contact:

Re: Savegame technical suggestions

Post by hoho »

Using copy-on-write for the game state would also make it easier to rewrite the game logic itself in multithreaded way.

User avatar
Ohz
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Feb 03, 2015 11:40 am
Contact:

Re: Savegame technical suggestions

Post by Ohz »

I was about to write a topic about.

Without replay, the savegame lost half of his size. When you play multiplayer on giant map after 20 hours of game, and experience some desync, sharing the map again and again can take the whole evening...
I'm not english, sorry for my mistakes

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Savegame technical suggestions

Post by ssilk »

Technically a snapshot is needed. Cause a save can represent a game only after one tick.

A copy-on-write would mean, that the game copies all chunks in one tick, then doing the save with the copy. While saving, it continues the game. With large maps, that copy will take a while.

Snapshot can work so: at time x all chunks cannot be modified anymore, only read access is possible. The save routine saves all chunks and some more, while the game engine continues. If a chunk then needs to be modified, it is copied first, then modified.
After save, the modified chunks are moved back over the old.

(In practice a lot more complicated)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

quinor
Filter Inserter
Filter Inserter
Posts: 404
Joined: Thu Mar 07, 2013 3:07 pm
Contact:

Re: Savegame technical suggestions

Post by quinor »

What I meant is when you change game state, you apply these changes to two game state copies - current and "savegame" one. When you want to save the game, you stop applying more changes to "savegame" (instead queue them somewhere), save the game from "savegame" state copy (of course parallelly) and then apply all queued changes. It should be decently fast and allow 90% non-freeze savegame, maybye with slight FPS loss.

starholme
Fast Inserter
Fast Inserter
Posts: 201
Joined: Tue Oct 21, 2014 7:25 pm
Contact:

Re: Savegame technical suggestions

Post by starholme »

Disabled replay would be simple to add I think, and for most games it would be fine.

The copy on write stuff is fairly complex. Even the 'two copies' is more complex than you might expect, and requires a possibly significant amount of extra ram for the second copy. You also double the amount of time it takes to update the changes each tick(you only calculate once, but you need to update two copies now), because it needs to be done in both places.

quinor
Filter Inserter
Filter Inserter
Posts: 404
Joined: Thu Mar 07, 2013 3:07 pm
Contact:

Re: Savegame technical suggestions

Post by quinor »

I know the technical diffucities, but as far as I know only about ~20mb of ram is the game state itself and it's not that much. Also, write time is not very significant on UPS (belt and inserter updates are many times that), so copy-on-write shouldn't be significant on game performance. Only thing I'd consider is developer time it'd take to implement that, it's true it may take quite long.

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: Savegame technical suggestions

Post by immibis »

ssilk wrote:Technically a snapshot is needed. Cause a save can represent a game only after one tick.

A copy-on-write would mean, that the game copies all chunks in one tick, then doing the save with the copy. While saving, it continues the game. With large maps, that copy will take a while.

Snapshot can work so: at time x all chunks cannot be modified anymore, only read access is possible. The save routine saves all chunks and some more, while the game engine continues. If a chunk then needs to be modified, it is copied first, then modified.
After save, the modified chunks are moved back over the old.
Um, that is copy-on-write.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Savegame technical suggestions

Post by bobingabout »

I suppose one technical difficulty with the "copy-on-write" thing is you may still need to pause the game to perform the RAM copy so that it can compress it into a savegame in a thread afterwards.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
Tr1cKy
Burner Inserter
Burner Inserter
Posts: 16
Joined: Thu Apr 16, 2015 1:16 pm
Contact:

Re: Savegame technical suggestions

Post by Tr1cKy »

Potentially super technical now - but basically btrfs and zfs filesystems work *very* efficiently doing copy-on-write on *everything*. It can be done efficiently. That doesn't mean it is easy though. :-/
And lo He said: "Bring unto Me the
Book of Blueprints
!"

Post Reply

Return to “Ideas and Suggestions”