Skip to content

Commit d3fff7c

Browse files
committed
zstd: Supports full zstd compression configuration
Reference configuration: https://github.com/facebook/zstd/blob/v1.5.6/lib/compress/clevels.h
1 parent bdf37ff commit d3fff7c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/ulog/file/zstd_file_writer.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ namespace ulog::file {
1111

1212
class ZstdLimitFile final : public WriterInterface {
1313
public:
14-
explicit ZstdLimitFile(const size_t file_limit_size, const int zstd_level = 3, const int zstd_window_log = 0,
15-
const int zstd_chain_log = 0, const int zstd_hash_log = 0,
14+
explicit ZstdLimitFile(const size_t file_limit_size, const int zstd_level = 3, const int zstd_window_log = 14,
15+
const int zstd_chain_log = 14, const int zstd_hash_log = 15, const int zstd_search_log = 2,
16+
const int zstd_min_match = 4, const int zstd_target_length = 0, const int zstd_strategy = 2,
1617
const size_t zstd_max_frame_in = 8 << 20)
1718
: config_file_limit_size_(file_limit_size), config_zstd_max_frame_in_(zstd_max_frame_in) {
1819
zstd_out_buffer_.resize(16 * 1024);
@@ -24,6 +25,10 @@ class ZstdLimitFile final : public WriterInterface {
2425
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_windowLog, zstd_window_log);
2526
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_chainLog, zstd_chain_log);
2627
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_hashLog, zstd_hash_log);
28+
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_searchLog, zstd_search_log);
29+
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_minMatch, zstd_min_match);
30+
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_targetLength, zstd_target_length);
31+
ZSTD_CCtx_setParameter(zstd_cctx_, ZSTD_c_strategy, zstd_strategy);
2732
}
2833

2934
~ZstdLimitFile() override {

tools/logrotate/logrotate.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ int main(const int argc, char *argv[]) {
8585
file_size, result.count("level") ? std::stoi(result.at("level")) : ZSTD_DEFAULT_LEVEL,
8686
result.count("window-log") ? std::stoi(result.at("window-log")) : 0,
8787
result.count("chain-log") ? std::stoi(result.at("chain-log")) : 0,
88-
result.count("hash-log") ? std::stoi(result.at("hash-log")) : 0);
88+
result.count("hash-log") ? std::stoi(result.at("hash-log")) : 0,
89+
result.count("search-log") ? std::stoi(result.at("search-log")) : 0,
90+
result.count("min-match") ? std::stoi(result.at("min-match")) : 0,
91+
result.count("target-length") ? std::stoi(result.at("target-length")) : 0,
92+
result.count("strategy") ? std::stoi(result.at("strategy")) : 0);
8993

9094
// No zstd parameters
9195
} else {

0 commit comments

Comments
 (0)