From: Yann Collet Date: Fri, 25 Oct 2024 23:08:22 +0000 (-0700) Subject: expose new parameter ZSTD_c_blockSplitter_level X-Git-Tag: v1.5.7^2~68^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=226ae73311d1ffd0c3488d8bc6a59576d910d6d4;p=thirdparty%2Fzstd.git expose new parameter ZSTD_c_blockSplitter_level --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 05edcd201..fbc11349e 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -603,6 +603,11 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param) bounds.upperBound = (int)ZSTD_ps_disable; return bounds; + case ZSTD_c_blockSplitter_level: + bounds.lowerBound = 0; + bounds.upperBound = ZSTD_BLOCKSPLITTER_LEVEL_MAX; + return bounds; + case ZSTD_c_useRowMatchFinder: bounds.lowerBound = (int)ZSTD_ps_auto; bounds.upperBound = (int)ZSTD_ps_disable; @@ -669,6 +674,7 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param) case ZSTD_c_minMatch: case ZSTD_c_targetLength: case ZSTD_c_strategy: + case ZSTD_c_blockSplitter_level: return 1; case ZSTD_c_format: @@ -755,6 +761,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value) case ZSTD_c_blockDelimiters: case ZSTD_c_validateSequences: case ZSTD_c_useBlockSplitter: + case ZSTD_c_blockSplitter_level: case ZSTD_c_useRowMatchFinder: case ZSTD_c_deterministicRefPrefix: case ZSTD_c_prefetchCDictTables: @@ -980,6 +987,11 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams, CCtxParams->postBlockSplitter = (ZSTD_paramSwitch_e)value; return CCtxParams->postBlockSplitter; + case ZSTD_c_blockSplitter_level: + BOUNDCHECK(ZSTD_c_blockSplitter_level, value); + CCtxParams->preBlockSplitter_level = value; + return (size_t)CCtxParams->preBlockSplitter_level; + case ZSTD_c_useRowMatchFinder: BOUNDCHECK(ZSTD_c_useRowMatchFinder, value); CCtxParams->useRowMatchFinder = (ZSTD_paramSwitch_e)value; @@ -1138,6 +1150,9 @@ size_t ZSTD_CCtxParams_getParameter( case ZSTD_c_useBlockSplitter : *value = (int)CCtxParams->postBlockSplitter; break; + case ZSTD_c_blockSplitter_level : + *value = CCtxParams->preBlockSplitter_level; + break; case ZSTD_c_useRowMatchFinder : *value = (int)CCtxParams->useRowMatchFinder; break; diff --git a/lib/zstd.h b/lib/zstd.h index 3a88c74d1..c1ad26a8d 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -496,6 +496,7 @@ typedef enum { * ZSTD_c_prefetchCDictTables * ZSTD_c_enableSeqProducerFallback * ZSTD_c_maxBlockSize + * ZSTD_c_blockSplitter_level * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. * note : never ever use experimentalParam? names directly; * also, the enums values themselves are unstable and can still change. @@ -518,7 +519,8 @@ typedef enum { ZSTD_c_experimentalParam16=1013, ZSTD_c_experimentalParam17=1014, ZSTD_c_experimentalParam18=1015, - ZSTD_c_experimentalParam19=1016 + ZSTD_c_experimentalParam19=1016, + ZSTD_c_experimentalParam20=1017 } ZSTD_cParameter; typedef struct { @@ -2236,7 +2238,6 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo * that overrides the default ZSTD_BLOCKSIZE_MAX. It cannot be used to set upper * bounds greater than ZSTD_BLOCKSIZE_MAX or bounds lower than 1KB (will make * compressBound() inaccurate). Only currently meant to be used for testing. - * */ #define ZSTD_c_maxBlockSize ZSTD_c_experimentalParam18 @@ -2264,6 +2265,24 @@ ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const vo */ #define ZSTD_c_searchForExternalRepcodes ZSTD_c_experimentalParam19 +/* ZSTD_c_blockSplitter_level + * note: this parameter only influences the first splitter stage, + * which is active before producing the sequences. + * ZSTD_c_useBlockSplitter influence the next splitter stage, + * which is active after sequence production, + * and is more accurate but also slower. + * Both can be combined. + * Allowed values are between 0 and 6. + * 0 means "auto", which will select a value depending on current ZSTD_c_strategy. + * 1 means no splitting. + * Then, values from 2 to 6 are sorted in increasing cpu load order. + * + * Note that currently the first block is never split, + * to ensure expansion guarantees in presence of incompressible data. + */ +#define ZSTD_BLOCKSPLITTER_LEVEL_MAX 6 +#define ZSTD_c_blockSplitter_level ZSTD_c_experimentalParam20 + /*! ZSTD_CCtx_getParameter() : * Get the requested compression parameter value, selected by enum ZSTD_cParameter, * and store it into int* value.