Beosar said:
There is read-only data, like the generated structures, and data that can change when a player is nearby, including the blocks they placed/removed and plants that grow etc. Chunks far away from the player are not loaded and therefore not modified.
I think the best thing to do is to generate the archive once an entire planet is unloaded and then delete all the files and when it is loaded again, all writeable data is unpacked when accessed and the read-only stuff can stay in the archive and is only read into memory.
So something like Minecraft? Where I think unloaded chunks are really just on the disk in a directory of files (taking advantage of the file system to deal with this, which generally means “wasting” a lot of space in case files grow, get deleted/replaced, etc., but in a way it can reclaim. Also why many filesystems really hate being like 90%+ full. I believe for example FAT32 doesn't do this, and fragmentation was a huge issue, ), not in RAM at all (and generally any backups of a live game needs special consideration, don't just copy/zip/etc. the directory on a live server/game)?
I think zip or other similar common formats are potentially still a good solution for backups. Potentially to keep the regular “in-use” game size down you might want to compress the stored chunks anyway, use something like deflate or some other commonly support algorithm, and then they are even in the right format, creating the zip backup/"save" is mostly concatenating files with some headers inbetween, or potentially something like tar (while normally a tar contains mostly uncompressed files, then say gzip is used on the whole thing, nothing technically says it must be. In “normal usage”, doing the gzip/etc. on top an archive of say JPEG, PNG, MP3, etc. files is largely a waste of time).
As for general performance, small files are bad. Putting lots of small files into some sort of archive then randomly accessing them is still bad, and at best intelligent caching (by the OS and/or say user mode database engines) in memory saves you (oh you just wrote that? well I kept a hot copy here for you. You want this tiny file/row/record that comes after the last one? Well lucky you I read a X KB page last time and kept it, and it happens to include the thing you want now as well).
One consideration is to make sure that the size of the “chunks” you store to disk is fairly large, computers have lots of memory today, what is a 20MB block instead of 40 separate 500KB items? These chunks might be different to what is actively updated in game, for example you might combine 3x3 chunks into a block for IO purposes and save/load them together.
EDIT: I just searched, this is in fact basically how Minecraft does it. While chunks are 16x16x256 blocks, 32x32 chunks (so 512x512x256 blocks) are a “region”. The game saves/loads that entire region as one individual file.