[Suggestion] Speed up the save process

(previously 'DEVELOPER') Private forum for registered community members. To register, please visit www.prison-architect.com/register.

Moderator: NBJeff

User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Re: [Suggestion] Speed up the save process

Postby xander » Tue Jun 03, 2014 1:12 am

b0rk wrote:
xander wrote:I disagree. One of the really nice features of Introversion's games is that the save files can easily be edited by hand without requiring that much technical knowledge <snip> An open, easily edited, plain text save file format is a feature, not a bug.


I actually agree that the text save files are a feature and I would like them to remain personally. However if the time penalty is in serialisation I don't really see what could be done to reduce this without making to format more efficient, I assume IV have semi optimised serialisation routines taken from previous games so the quick wins optimisation wise may well have been taken. Loads for example appear to be remarkably rapid.

Please forgive me if I mangle terminology (or simply ignore it)---I am a mathematician, not a computer scientist---but perhaps a combination of the two is the correct solution? A more efficient "save file" format that can be held in RAM and passed to a parallel thread which unpacks the data in RAM writes the human-readable save file to disk?

xander
b0rk
level1
level1
Posts: 12
Joined: Sun Sep 15, 2013 5:29 pm

Re: [Suggestion] Speed up the save process

Postby b0rk » Tue Jun 03, 2014 2:30 am

As nzjoe87 points out computation time with data structures is never non trivial.

Your basically proposing a in-place memory copy of the data structures some times referred to as a deep copy which was the alternative I hinted at in place of making the file format more efficient. Depending on how you create the clone will have major influence on performance. object copy

Do you iterate over every item in the master collection allowing for self serialisation or manually copy the properties over, iterating over sub objects each time. Self serialisation has the benefit of encapsulating the clone within the class (object) much safer to implement on a changing code base where classes and class properties will change during development but potentially slower if you try use say reflection.

Once you have such a clone then yes a worker (secondary) thread could serialise the structure down to plain text for persistence.

The game would have to pause during the cloning process.

If you wanted to be really slick then the whole data structure could be made observable (change aware) so that multiple threads could access the structure directly. You'd need to manage locking when a thread wished to change a value or allow for transactions and temporary copies of old data, if implemented well then saves would become a background task with the game continuing uninterrupted. This would have the potential for lots of fun crash / corruption bugs that are a PITA to resolve.
User avatar
paktsardines
level5
level5
Posts: 1752
Joined: Mon Oct 01, 2012 11:10 am
Location: Australia

Re: [Suggestion] Speed up the save process

Postby paktsardines » Thu Jun 05, 2014 1:17 am

Glad we have finally reached consensus on this. It is more trouble than it's worth and the effort would be better spent elsewhere.

Personally I don't mind the game pausing while it saves anyway.

Return to “Community Members”

Who is online

Users browsing this forum: No registered users and 1 guest