# Save compressing?

**URL:** https://discourse.cataclysmdda.org/t/save-compressing/15201
**Category:** The Drawing Board
**Created:** [March 27, 2018, 9:48pm UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201 "2018-03-27T21:48:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [March 27, 2018, 9:48pm UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/1 "2018-03-27T21:48:42Z")

</div>

The world folder gets pretty fast after traveling for a while.

But the save files also compress extremely well. My 150 MB save folder compresses into 9 MB archive (7z fastest).

So compressing the save folder/files would drastically reduce the size of the save.

Just throwing this idea here to be told how hard it would be to do.

---

<div class="post-metadata">

### Author: ![darktoes](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@darktoes](https://discourse.cataclysmdda.org/u/darktoes)
#### Post date: [March 27, 2018, 9:54pm UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/2 "2018-03-27T21:54:30Z")

</div>

That would probably cause issues with saves you’re trying to play, but I’m definitely gonna go compress my old saves. Thanks for the info.

---

<div class="post-metadata">

### Author: ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)
#### Post date: [March 27, 2018, 11:59pm UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/3 "2018-03-27T23:59:55Z")

</div>

It’s pretty trivial to do, though it limits compression ratio if each file is compressed individually.  
The kind of annoying thing is it requires taking a dependency on a compression library.

---

<div class="post-metadata">

### Author: ![darktoes](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@darktoes](https://discourse.cataclysmdda.org/u/darktoes)
#### Post date: [March 28, 2018, 12:03am UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/4 "2018-03-28T00:03:25Z")

</div>

Wouldn’t it mess with load/calculation times if it has everything it’s trying to read compressed?

---

<div class="post-metadata">

### Author: ![Hirmuolio](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@Hirmuolio](https://discourse.cataclysmdda.org/u/Hirmuolio)
#### Post date: [March 28, 2018, 11:31am UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/5 "2018-03-28T11:31:55Z")

</div>

Even if the files are compressed individually the save game would become much smaller. The majority of the save size comes from the tens of thousands of small ~7000 B map files. These compress into ~600 B each.

Compressing/decompressing shouldn’t have very big impact on load times. I think the game only loads the parts that are near you so only some of the files would need to be opened and saved at once. Compressing one map block folder is so fast that you don’t even see the 7z to open before it already closes. It is even possible that on HDD the loading and saving could be faster as there is lesss to write and save to disk.

---

<div class="post-metadata">

### Author: ![Coolthulhu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/coolthulhu/32/2446_2.png) [@Coolthulhu](https://discourse.cataclysmdda.org/u/Coolthulhu)
#### Post date: [March 29, 2018, 1:41am UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/6 "2018-03-29T01:41:05Z")

</div>

> though it limits compression ratio if each file is compressed individually

zstd [GitHub - facebook/zstd: Zstandard - Fast real-time compression algorithm](https://github.com/facebook/zstd) can use a common pre-learned dictionary for many files, which would handle our (very similar) jsons well.  
Though I’m not sure about how legal would it be, since it the implementation is dual licensed under GPL2 and BSD.

---

<div class="post-metadata">

### Author: ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)
#### Post date: [March 29, 2018, 4:50am UTC](https://discourse.cataclysmdda.org/t/save-compressing/15201/7 "2018-03-29T04:50:41Z")

</div>

This header-only library would make adding gzip compression to dda pretty trivial: [https://github.com/mateidavid/zstr](https://github.com/mateidavid/zstr)  
Just adjust functions that open the save files with the wrappers from this library and you’re done.

I’m not a fan of adding a dependency on something relatively obscure like zstd, but if it delivers on that high compression ratio with tiny files it’ll be worth it.
