From: Igor Fedotov Date: Fri, 14 Oct 2016 13:44:47 +0000 (+0000) Subject: common/compressor/ZLibCompressor: add a config option to specify compression level X-Git-Tag: v11.1.0~639^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f331597fba18c287f389ad36b2a18e86fa1dafbb;p=ceph.git common/compressor/ZLibCompressor: add a config option to specify compression level Signed-off-by: Igor Fedotov --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 992895e286a7..74fac89b2352 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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") diff --git a/src/compressor/zlib/ZlibCompressor.cc b/src/compressor/zlib/ZlibCompressor.cc index cb8c0b06d310..45338588be37 100644 --- a/src/compressor/zlib/ZlibCompressor.cc +++ b/src/compressor/zlib/ZlibCompressor.cc @@ -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;