]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add compatibility for multithreading
authorsenhuang42 <senhuang96@fb.com>
Mon, 19 Oct 2020 16:07:06 +0000 (12:07 -0400)
committersenhuang42 <senhuang96@fb.com>
Mon, 19 Oct 2020 16:07:06 +0000 (12:07 -0400)
lib/compress/zstd_compress.c
lib/compress/zstdmt_compress.c

index 434c23000d80def36ecbd78b709ddffbdfe70099..0bfaeec4f84b93c2c551ae1e59a4cfd0183166f0 100644 (file)
@@ -1542,7 +1542,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
 
     zc->isFirstBlock = 1;
 
-    if (params.cParams.strategy >= ZSTD_btopt && params.cParams.windowLog >= 27) {
+    if (params.cParams.strategy >= ZSTD_btopt && params.cParams.windowLog >= 27 && params.nbWorkers == 0) {
         /* Enable LDM by default for optimal parser and window size >= 128MB */
         DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
         params.ldmParams.enableLdm = 1;
index d68f4718952961a351fb9d0089eeecdae7830e44..bf4782cddd516b50c2244e29bbd69d8eb4de8c20 100644 (file)
@@ -1459,6 +1459,13 @@ size_t ZSTDMT_initCStream_internal(
 
     mtctx->params = params;
     mtctx->frameContentSize = pledgedSrcSize;
+
+    if (params.cParams.strategy >= ZSTD_btopt && params.cParams.windowLog >= 27) {
+        /* Enable LDM by default for optimal parser and window size >= 128MB */
+        DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
+        params.ldmParams.enableLdm = 1;
+    }
+
     if (dict) {
         ZSTD_freeCDict(mtctx->cdictLocal);
         mtctx->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,