[Zlib-devel] minigzip vs. my own zlib client
Mikhail Teterin
mi+zlib at aldan.algebra.com
Sun Jun 4 18:06:32 EDT 2006
Although the e-mail below, apparently, never reached the mailing list (Mark is
looking into the delivery problem), I have already solved the problem.
Using `9' for memLevel, as I do in the below call to deflateInit2, causes BOTH
a slight increase in the output size, AND a very substantial performance hit.
The comment in zlib.h says:
The memLevel parameter specifies how much memory should be allocated
for the internal compression state. memLevel=1 uses minimum memory but
is slow and reduces compression ratio; memLevel=9 uses maximum memory
for optimal speed. The default value is 8. See zconf.h for total memory
usage as a function of windowBits and memLevel.
That is not true -- at least, not on my Opteron (FreeBSD/amd64). Using 8 is
much faster AND more efficient, than 9... Looks like a bug...
-mi
On Tuesday 30 May 2006 21:30, Mikhail Teterin wrote:
= Hello!
=
= I'm writing my own zlib client, intended to compress files, which are almost
= always cached in memory (just created). Knowing this, my program mmap-s them
= and calls deflate() with the very large buffers at once (512Mb is the
= default).
=
= It all works, but, for some reason, the minigzip-created archives are
= slightly (like 1.1%) smaller than those created by my program -- using the
= same -9 level. Both can be decompressed into the identical original, so
= there is no problem with correctness, just compressing efficiency...
=
= Can anyone speculate, why this would be? I create the stream with:
=
= deflateInit2(&stream.gz, level, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY);
=
= What is minigzip doing differently? Thanks!
=
= -mi
More information about the Zlib-devel
mailing list