]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
compressor: Add a config option to specify Zstd compression level
authorBryan Stillwell <bstillwell@godaddy.com>
Fri, 6 Mar 2020 17:58:50 +0000 (10:58 -0700)
committerBryan Stillwell <bstillwell@godaddy.com>
Fri, 18 Sep 2020 21:23:21 +0000 (15:23 -0600)
Add a new configuration item called 'compressor_zstd_level' so that the
Zstandard compression level can be tuned to the workload on a cluster.

Fixes: https://tracker.ceph.com/issues/43377
Signed-off-by: Bryan Stillwell <bstillwell@godaddy.com>
(cherry picked from commit 82699067b89eab01744f1b7f10490ec0975bb1a6)

src/common/legacy_config_opts.h
src/common/options.cc
src/compressor/zstd/CompressionPluginZstd.h
src/compressor/zstd/ZstdCompressor.h

index 020889e9298585041779389404489a34b14bf792..586b3f6d8e161a4859435ab768a405824ee65474 100644 (file)
@@ -96,6 +96,7 @@ OPTION(xio_max_send_inline, OPT_INT) // xio maximum threshold to send inline
 
 OPTION(compressor_zlib_isal, OPT_BOOL)
 OPTION(compressor_zlib_level, OPT_INT) //regular zlib compression level, not applicable to isa-l optimized version
+OPTION(compressor_zstd_level, OPT_INT) //regular zstd compression level
 
 OPTION(qat_compressor_enabled, OPT_BOOL)
 
index 3538f061abbf925aa6dd9bb574e3a794d035301c..280f85d932fc76f3294f4cbd2c03ce60aa1a3d3c 100644 (file)
@@ -816,6 +816,10 @@ std::vector<Option> get_global_options() {
     .set_default(5)
     .set_description("Zlib compression level to use"),
 
+    Option("compressor_zstd_level", Option::TYPE_INT, Option::LEVEL_ADVANCED)
+    .set_default(5)
+    .set_description("Zstd compression level to use"),
+
     Option("qat_compressor_enabled", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
     .set_description("Enable Intel QAT acceleration support for compression if available"),
index c85951705a40626f882c47595338b537dbb24739..72ef9c45ce0106a2b4120ed07e55d129476fec9f 100644 (file)
@@ -32,7 +32,7 @@ public:
                       std::ostream *ss) override
   {
     if (compressor == 0) {
-      ZstdCompressor *interface = new ZstdCompressor();
+      ZstdCompressor *interface = new ZstdCompressor(cct);
       compressor = CompressorRef(interface);
     }
     *cs = compressor;
index 0b17c99ad13d6ded186ed8cf45016ef27d38a01e..83508b93b45e6027338b9885501b34ac8a7a0228 100644 (file)
 #include "include/encoding.h"
 #include "compressor/Compressor.h"
 
-#define COMPRESSION_LEVEL 5
-
 class ZstdCompressor : public Compressor {
  public:
-  ZstdCompressor() : Compressor(COMP_ALG_ZSTD, "zstd") {}
+  ZstdCompressor(CephContext *cct) : Compressor(COMP_ALG_ZSTD, "zstd"), cct(cct) {}
 
   int compress(const bufferlist &src, bufferlist &dst) override {
     ZSTD_CStream *s = ZSTD_createCStream();
-    ZSTD_initCStream_srcSize(s, COMPRESSION_LEVEL, src.length());
+    ZSTD_initCStream_srcSize(s, cct->_conf->compressor_zstd_level, src.length());
     auto p = src.begin();
     size_t left = src.length();
 
@@ -101,6 +99,8 @@ class ZstdCompressor : public Compressor {
     dst.append(dstptr, 0, outbuf.pos);
     return 0;
   }
+ private:
+  CephContext *const cct;
 };
 
 #endif