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.
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.)
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.
4096x4096 map
level | size (kB) | load (ms) | save (ms) |
1 | 29107 | 2880 | 1360 |
6 | 19549 | 2880 | 3440 |
9 | 18244 | 2870 | 16575 |
default | 19556 | 2870 | 3450 |
bzip def | 9748 | 4275 | 33380 |
binary | 221657 | 2850 | 1270 |
Hard to beat the zip default IMO.
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.
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.