php-memcached-dev / php-memcached

memcached extension based on libmemcached library
Other
990 stars 323 forks source link

Make the compression_level at settable option and expand it to zlib #540

Closed rlerdorf closed 1 year ago

rlerdorf commented 1 year ago

Make it possible to use setOption to set Memcached::OPT_COMPRESSION_LEVEL which I had missed in my original zstd PR https://github.com/php-memcached-dev/php-memcached/pull/539

zlib compression was using the default zlib compression level of 6. With this PR it is now possible to choose other levels for zlib as well. I have left the default at 6 so nothing will change for people upgrading unless they explicitly set a different level.

And here is some more bench marking data using php serialized data - https://gist.github.com/rlerdorf/b9bae385446d5a30b65e6e241e34d0a8

From this I think it is clear that fastlz is not really useful at any value size anymore. If you are looking for lightning quick compression and decompression, zstd at level 1 is generally a better choice.

I did not apply the compression_level to fastlz because it only has 2 and it currently switches from 1 to 2 automatically for values larger than 65535 bytes. Forcing it to one or the other doesn't seem useful.