]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add ZSTD_c_enableDedicatedDictSearch Param
authorBimba Shrestha <bimbashrestha@fb.com>
Thu, 11 Jun 2020 20:21:28 +0000 (13:21 -0700)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Sep 2020 22:51:52 +0000 (18:51 -0400)
lib/compress/zstd_compress.c
lib/compress/zstd_compress_internal.h
lib/zstd.h

index 61369687a8698cf22d9eacc8c8433fe49768b8fa..0e3eb9e25f9c2cfdeaa0611638d90cd99bb25d77 100644 (file)
@@ -353,6 +353,11 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
 #endif
         return bounds;
 
+    case ZSTD_c_enableDedicatedDictSearch:
+        bounds.lowerBound = 0;
+        bounds.upperBound = 1;
+        return bounds;
+
     case ZSTD_c_enableLongDistanceMatching:
         bounds.lowerBound = 0;
         bounds.upperBound = 1;
@@ -464,6 +469,7 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
     case ZSTD_c_jobSize:
     case ZSTD_c_overlapLog:
     case ZSTD_c_rsyncable:
+    case ZSTD_c_enableDedicatedDictSearch:
     case ZSTD_c_enableLongDistanceMatching:
     case ZSTD_c_ldmHashLog:
     case ZSTD_c_ldmMinMatch:
@@ -514,6 +520,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
     case ZSTD_c_jobSize:
     case ZSTD_c_overlapLog:
     case ZSTD_c_rsyncable:
+    case ZSTD_c_enableDedicatedDictSearch:
     case ZSTD_c_enableLongDistanceMatching:
     case ZSTD_c_ldmHashLog:
     case ZSTD_c_ldmMinMatch:
@@ -667,6 +674,10 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
         return CCtxParams->rsyncable;
 #endif
 
+    case ZSTD_c_enableDedicatedDictSearch :
+        CCtxParams->enableDedicatedDictSearch = (value!=0);
+        return CCtxParams->enableDedicatedDictSearch;
+
     case ZSTD_c_enableLongDistanceMatching :
         CCtxParams->ldmParams.enableLdm = (value!=0);
         return CCtxParams->ldmParams.enableLdm;
@@ -794,6 +805,9 @@ size_t ZSTD_CCtxParams_getParameter(
         *value = CCtxParams->rsyncable;
         break;
 #endif
+    case ZSTD_c_enableDedicatedDictSearch :
+        *value = CCtxParams->enableDedicatedDictSearch;
+        break;
     case ZSTD_c_enableLongDistanceMatching :
         *value = CCtxParams->ldmParams.enableLdm;
         break;
index 4760f6b08c6a5fb6d14326313fdb45d4bad51218..b8e7496cadabc1316162c01887cdfd0a3889e590 100644 (file)
@@ -228,6 +228,9 @@ struct ZSTD_CCtx_params_s {
     /* Long distance matching parameters */
     ldmParams_t ldmParams;
 
+    /* Dedicated dict search algorithm trigger */
+    int enableDedicatedDictSearch;
+
     /* Internal use, for createCCtxParams() and freeCCtxParams() only */
     ZSTD_customMem customMem;
 };  /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
index 4e9fd93bd386ae78a7fca5186ac7261fb7f12751..ea3e46532babaa563101076a2420eb2b2b5ad017 100644 (file)
@@ -361,6 +361,21 @@ typedef enum {
                               * Deviating far from default value will likely result in a compression ratio decrease.
                               * Special: value 0 means "automatically determine hashRateLog". */
 
+    ZSTD_c_enableDedicatedDictSearch=170, /* Enable the use of the match finder specifically for
+                                           * dictionaries. This has several implications:
+                                           * 1) We may override cDict params supplied using
+                                           *    ZSTD_refCDict because the dedicated match finder
+                                           *    needs to enforce some unique invariants on the
+                                           *    hashLog and chainLog.
+                                           * 2) We will force the dict to be attached
+                                           * 3) We will pick cParams based on ZSTD_c_compressionLevel
+                                           *    and the size of the dictionary which will increase
+                                           *    the cDict memory usage.
+                                           * 4) We will only do this for certain supported levels.
+                                           *    The exact levels which are supported are determined
+                                           *    by ZSTD_c_compressionLevel and dictionary size.
+                                           *    (only ZSTD_greedy, ZSTD_lazy and ZSTD_lazy2) */
+
     /* frame parameters */
     ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
                               * Content size must be known at the beginning of compression.