@supermalparit
My saved game is around 28 MB (zip File around 760 KB).
When saving you first write the whole 28 MB to a file and then zip it.
When loading you unzip the file to disk and then read the 28 MB file from disk.
Wouldn't it be faster if you write/read from a zip stream directly? Should be easy to change in theory. (Not that I have done something like this... so there may be all sorts of pitfalls...)
Are you only storing data that is in memory while the game runs or is there more data floating around somewhere else?
When I load my 28 MB saved game file the java process only takes up 613 KB. Why are saved games so insanely large? (It's normal that they take up more space... but isn't there a way to store it more efficiently?)
Also I noticed that you seem to read/write java objects to the file (using the standard serialization?). If you change a java class then the saved game will break.
Would it not be a good idea to implement a serialization that takes up less space and does not break every time a java class is modified? (I'm not thinking that we need this during Alpha or maybe even Beta... but when you release the final game you should be able to make small changes to java classes without every time breaking the saved game. If you keep the current system it will be a nightmare. I'm sure you have already planed something and just keep the current simple save/load approach during development as it does not cost you time to change the serialization each time you add or change something.)
Anyway here are my numbers: (Just one try, it could be different the next time I try.)
C:(512MB) Load: 1:10 min, Save: 0:53 min
C:(1024MB) Load: 1:07 min, Save: 0:58 min
Added option "-Duser.home=." to save in the same folder where I start Towns from. (Towns is on my second hard drive with the drive letter 'S'.)
S:(512MB) Load: 0:33 min, Save: 0:25 min
S:(1024MB) Load: 0:33 min, Save: 0:25 min
ps. I'm not saying that slow/fast hard disk drives are the only cause of slow save/load times. But many things can go wrong with hard disk drives... anti virus scanning, (write) cache vs. no (write) cache (removable drives should not use write cache), pio instead of dma access, defect sectors, connecting drive on the wrong port on the motherboard, etc.
When I copy 28 MB from one drive to the other it happens in seconds... so the difference I noticed can't be because of a slow hard disk drive. (But maybe windows caches it.)
Even using 7zip to zip/unzip the file only takes a few seconds.
I also noticed that while saving/loading both CPUs of my dual core are at 50 to 90%. (Mostly at 50% though.)
So I guess the real slow part is the standard java serialization of objects... probably in combination with a huge amount of objects. Or maybe the use of too small buffers while writing/reading the files. Or lots of garbage collections while reading/writing files. I did not check the last thing... too late, need to get to bed.
