From 68a232c5917ff387031c76acea80f77e8115419f Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 23 Feb 2024 13:13:03 -0800 Subject: [PATCH] benchmark more can test targetCBlockSize --- programs/benchzstd.c | 3 +++ programs/benchzstd.h | 1 + programs/zstd.1.md | 4 ++++ programs/zstdcli.c | 1 + 4 files changed, 9 insertions(+) diff --git a/programs/benchzstd.c b/programs/benchzstd.c index 32227669f..29ee595c1 100644 --- a/programs/benchzstd.c +++ b/programs/benchzstd.c @@ -200,6 +200,7 @@ BMK_advancedParams_t BMK_initAdvancedParams(void) BMK_both, /* mode */ BMK_TIMETEST_DEFAULT_S, /* nbSeconds */ 0, /* blockSize */ + 0, /* targetCBlockSize */ 0, /* nbWorkers */ 0, /* realTime */ 0, /* additionalParam */ @@ -275,6 +276,8 @@ static void BMK_initCCtx( (int)adv->literalCompressionMode)); CHECK_Z(ZSTD_CCtx_setParameter( ctx, ZSTD_c_strategy, (int)comprParams->strategy)); + CHECK_Z(ZSTD_CCtx_setParameter( + ctx, ZSTD_c_targetCBlockSize, (int)adv->targetCBlockSize)); CHECK_Z(ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize)); } diff --git a/programs/benchzstd.h b/programs/benchzstd.h index cdb6101c2..ad3088cd4 100644 --- a/programs/benchzstd.h +++ b/programs/benchzstd.h @@ -100,6 +100,7 @@ typedef struct { BMK_mode_t mode; /* 0: all, 1: compress only 2: decode only */ unsigned nbSeconds; /* default timing is in nbSeconds */ size_t blockSize; /* Maximum size of each block*/ + size_t targetCBlockSize;/* Approximative size of compressed blocks */ int nbWorkers; /* multithreading */ unsigned realTime; /* real time priority */ int additionalParam; /* used by python speed benchmark */ diff --git a/programs/zstd.1.md b/programs/zstd.1.md index 231341b2a..9a4a5df2c 100644 --- a/programs/zstd.1.md +++ b/programs/zstd.1.md @@ -218,6 +218,10 @@ the last one takes effect. expected. This feature allows for controlling the guess when needed. Exact guesses result in better compression ratios. Overestimates result in slightly degraded compression ratios, while underestimates may result in significant degradation. +* `--target-compressed-block-size=#`: + Attempt to produce compressed blocks of approximately this size. + This will split larger blocks in order to approach this target. + Notably useful to improve latency when the receiver can make use of early data sooner. * `-o FILE`: save result into `FILE`. * `-f`, `--force`: diff --git a/programs/zstdcli.c b/programs/zstdcli.c index dd21021b0..85d0e12d7 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -1374,6 +1374,7 @@ int main(int argCount, const char* argv[]) CLEAN_RETURN(1); } benchParams.blockSize = blockSize; + benchParams.targetCBlockSize = targetCBlockSize; benchParams.nbWorkers = (int)nbWorkers; benchParams.realTime = (unsigned)setRealTimePrio; benchParams.nbSeconds = bench_nbSeconds;