]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
expose new parameter ZSTD_c_blockSplitter_level
authorYann Collet <cyan@fb.com>
Fri, 25 Oct 2024 23:08:22 +0000 (16:08 -0700)
committerYann Collet <cyan@fb.com>
Mon, 28 Oct 2024 23:31:15 +0000 (16:31 -0700)
lib/compress/zstd_compress.c
lib/zstd.h

index 05edcd2019ea35959f4d814e19c09d4d631015a1..fbc11349eb00d28ed71c338f67985f1a10cc362f 100644 (file)
@@ -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;
index 3a88c74d1d7d6d9aa3229a331e791d1508112830..c1ad26a8d0828d8cf7eb4d4ed2db527d6e0a13d4 100644 (file)
@@ -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.