Author Topic: Impact of zlib compression levels  (Read 534 times)

0 Members and 1 Guest are viewing this topic.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8657
  • Total likes: 284
  • Helpful: 226
  • Languages: De,EN,JP
Impact of zlib compression levels
« on: October 13, 2016, 09:09:31 PM »
I a blog on compiling the server I found a remark about explicitely setting the compression level to the lowest level of zlib via gzopen(filename, "wb1"). I tested this with my usual test game.

Code: [Select]
level size time for load/save
1 3664kb 4045/1393ms
6 2985kb 4052/1386ms
9 2882kb 4042/5110ms
default 2975kb 4144/1507ms

One can argue to set it to level six; but the default already does a good job too. Exspecially that at good downlaod rates of 16 MBit (or realistic about one MB per second) the differences between level 1 and default are 200 ms longer compression but 600 ms shorter download.

Anyway, nice to know there is a parameter to play around. (And I am happy to see your impact.)

Offline DrSuperGood

Re: Impact of zlib compression levels
« Reply #1 on: October 13, 2016, 11:40:50 PM »
Maybe some sort of algorithm could be used to select an appropriate compression level? Specifically if a person with a slow connection is trying to join then it uses a higher compression level. Would need extensive statistical testing to get the algorithm to be vaguely accurate.

Offline TurfIt

Re: Impact of zlib compression levels
« Reply #2 on: October 14, 2016, 01:08:32 AM »
4096x4096 map
levelsize (kB)    load (ms)    save (ms)
1  291072880  1360
6  195492880  3440
9  18244287016575
default  195562870  3450
bzip def        9748427533380
binary2216572850  1270

Hard to beat the zip default IMO.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8657
  • Total likes: 284
  • Helpful: 226
  • Languages: De,EN,JP
Re: Impact of zlib compression levels
« Reply #3 on: October 14, 2016, 08:38:25 AM »
When you have a server with a slow upload then you can already use bzip. That gives better compression than any zip mode.

NB: The same method of forcing a level can be done for bzip. But again default does a good job too, albeit a much slower one than zip.

Offline DrSuperGood

Re: Impact of zlib compression levels
« Reply #4 on: October 14, 2016, 03:42:16 PM »
Might be a good idea to add a special "maximum compression" save option that uses the maximum compression level. Although not at all practical for servers or single player saving, it would be intended for save game publication. For example hand-made maps or scenarios could be saved with such a configuration for smaller file size so they are quicker to download.