From: senhuang42 Date: Mon, 19 Oct 2020 16:07:06 +0000 (-0400) Subject: Add compatibility for multithreading X-Git-Tag: v1.4.7~44^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1c7fc57687e208b82bcbe46387f6de5d5052d94;p=thirdparty%2Fzstd.git Add compatibility for multithreading --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 434c23000..0bfaeec4f 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -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; diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index d68f47189..bf4782cdd 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -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,