Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octopus: compressor: Add a config option to specify Zstd compression level #37118

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/legacy_config_opts.h
Expand Up @@ -82,6 +82,7 @@ SAFE_OPTION(plugin_dir, OPT_STR)

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)

Expand Down
4 changes: 4 additions & 0 deletions src/common/options.cc
Expand Up @@ -785,6 +785,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(1)
.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"),
Expand Down
2 changes: 1 addition & 1 deletion src/compressor/zstd/CompressionPluginZstd.h
Expand Up @@ -32,7 +32,7 @@ class CompressionPluginZstd : public CompressionPlugin {
std::ostream *ss) override
{
if (compressor == 0) {
ZstdCompressor *interface = new ZstdCompressor();
ZstdCompressor *interface = new ZstdCompressor(cct);
compressor = CompressorRef(interface);
}
*cs = compressor;
Expand Down
8 changes: 4 additions & 4 deletions src/compressor/zstd/ZstdCompressor.h
Expand Up @@ -22,15 +22,13 @@
#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();

Expand Down Expand Up @@ -101,6 +99,8 @@ class ZstdCompressor : public Compressor {
dst.append(dstptr, 0, outbuf.pos);
return 0;
}
private:
CephContext *const cct;
};

#endif