From 99bfda84e63260bf6f9db699500198c9d0948b89 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 17 Oct 2024 14:46:47 -0700 Subject: [PATCH] only split full blocks short term simplification --- lib/compress/zstd_compress.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 25a11f070..11c8ceabd 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -4491,10 +4491,15 @@ static void ZSTD_overflowCorrectIfNeeded(ZSTD_matchState_t* ms, static size_t ZSTD_optimalBlockSize(const void* src, size_t srcSize, size_t blockSizeMax, ZSTD_strategy strat, S64 savings) { - if (strat >= ZSTD_btlazy2) - return ZSTD_splitBlock_4k(src, srcSize, blockSizeMax); + /* note: we currenly only split full blocks (128 KB) + * and when there is more than 128 KB input remaining + */ if (srcSize <= 128 KB || blockSizeMax < 128 KB) return MIN(srcSize, blockSizeMax); + /* dynamic splitting has a cpu cost for analysis, + * due to that cost it's only used for btlazy2+ strategies */ + if (strat >= ZSTD_btlazy2) + return ZSTD_splitBlock_4k(src, srcSize, blockSizeMax); /* blind split strategy * no cpu cost, but can over-split homegeneous data. * heuristic, tested as being "generally better". -- 2.47.2