common/compressor/ZLibCompressor: add a config option to specify compression level

Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
This commit is contained in:
Igor Fedotov 2016-10-14 13:44:47 +00:00
parent b9953a1e20
commit f331597fba
2 changed files with 2 additions and 4 deletions

View File

@ -98,6 +98,7 @@ OPTION(xio_transport_type, OPT_STR, "rdma") // xio transport type: {rdma or tcp}
OPTION(xio_max_send_inline, OPT_INT, 512) // xio maximum threshold to send inline
OPTION(compressor_zlib_isal, OPT_BOOL, false)
OPTION(compressor_zlib_level, OPT_INT, 5) //regular zlib compression level, not applicable to isa-l optimized version
OPTION(async_compressor_enabled, OPT_BOOL, false)
OPTION(async_compressor_type, OPT_STR, "snappy")

View File

@ -41,9 +41,6 @@ _prefix(std::ostream* _dout)
// default window size for Zlib 1.2.8, negated for raw deflate
#define ZLIB_DEFAULT_WIN_SIZE -15
// compression level we use. probably should be configurable...
#define ZLIB_COMPRESSION_LEVEL 5
// desired memory usage level. increasing to 9 doesn't speed things up
// significantly (helps only on >=16K blocks) and sometimes degrades
// compression ratio.
@ -61,7 +58,7 @@ int ZlibCompressor::zlib_compress(const bufferlist &in, bufferlist &out)
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit2(&strm, ZLIB_COMPRESSION_LEVEL, Z_DEFLATED, ZLIB_DEFAULT_WIN_SIZE, ZLIB_MEMORY_LEVEL, Z_DEFAULT_STRATEGY);
ret = deflateInit2(&strm, g_conf->compressor_zlib_level, Z_DEFLATED, ZLIB_DEFAULT_WIN_SIZE, ZLIB_MEMORY_LEVEL, Z_DEFAULT_STRATEGY);
if (ret != Z_OK) {
dout(1) << "Compression init error: init return "
<< ret << " instead of Z_OK" << dendl;