[pmwiki-users] zlib.output_compression_level

Patrick R. Michaud pmichaud at pobox.com
Sun Oct 1 11:20:24 CDT 2006


On Fri, Sep 29, 2006 at 11:30:21AM +0000, Anno wrote:
> > If that is true then why is the default setting 
> > set to 6 ?????
> 
> I don't know.
> 
> Here is the output of a test script (the source is at the bottom, feel free to
> check for yourself)
> [...]
> As you can see, level 6 takes more than 100% more time to do the job compare to
> level 2, for additional ~3% size reduction.
> 
> It is on you to decide whether it is worth it.

PHP's zlib function makes use of the zlib compression library, which is
used for a lot more than just PHP (e.g., the gzip command).  

As mentioned in the man page for gzip(1):

    The default compression level is [6] (that is, biased towards 
    high compression at expense of speed).

Of course, this makes good sense for compressing files on disk
(the whole point of compression is to save disk space), which is why
the library chose it.  But a different setting might make sense in
a web context, where speed is more important.

The people who created the zlib hooks into PHP probably felt
(as would I) that they should accept the library's default unless
explicitly told otherwise.  For example, on my system, PHP's default
setting of zlib.output_compression_level is -1, which means
"use the library default", and the library default is likely 6.
>From a toolwriter's perspective, this is simply the principle of
"don't arbitrarily reset defaults".

But as Anno's demonstration illustrates, using a compression level
of 2 may make a lot more sense in a real-time streaming web environment
due to the time savings involved.

Pm





More information about the pmwiki-users mailing list