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

nautilus: compressor: Add a config option to specity Zstd compression level #37219

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
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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