From 166901dc726691e31de143b9f570693256a1c953 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 19 Jun 2018 18:07:18 -0700 Subject: [PATCH] reduced POOL_resize() restriction It's not necessary to ensure that no job is ongoing. The pool is only expanded, existing threads are preserved. In case of error, the only option is to return NULL and terminate the thread pool anyway. --- lib/common/pool.c | 1 - lib/compress/zstdmt_compress.c | 2 +- lib/decompress/zstd_decompress.c | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/common/pool.c b/lib/common/pool.c index e64833f87..a0e2bedf0 100644 --- a/lib/common/pool.c +++ b/lib/common/pool.c @@ -188,7 +188,6 @@ size_t POOL_sizeof(POOL_ctx *ctx) { /* note : only works if no job is running ! */ static POOL_ctx* POOL_resize_internal(POOL_ctx* ctx, size_t numThreads) { - if (ctx->numThreadsBusy > 0) return NULL; if (numThreads <= ctx->threadCapacity) { ctx->threadLimit = numThreads; return ctx; diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 4a2a4cdd5..bbbdc5cd4 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -1280,7 +1280,7 @@ size_t ZSTDMT_initCStream_internal( /* init */ if (params.nbWorkers != mtctx->params.nbWorkers) - ZSTDMT_resize(mtctx, params.nbWorkers); + CHECK_F( ZSTDMT_resize(mtctx, params.nbWorkers) ); if (params.jobSize == 0) { params.jobSize = 1U << ZSTDMT_computeTargetJobLog(params); diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index 148c87f9d..4de98a8e6 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -1108,15 +1108,11 @@ size_t ZSTD_execSequence(BYTE* op, return sequenceLength; } /* span extDict & currentPrefixSegment */ - DEBUGLOG(2, "ZSTD_execSequence: found a 2-segments match") { size_t const length1 = dictEnd - match; - DEBUGLOG(2, "first part (extDict) is %zu bytes long", length1); memmove(oLitEnd, match, length1); op = oLitEnd + length1; sequence.matchLength -= length1; - DEBUGLOG(2, "second part (prefix) is %zu bytes long", sequence.matchLength); match = prefixStart; - DEBUGLOG(2, "first byte of 2nd part : %02X", *prefixStart); if (op > oend_w || sequence.matchLength < MINMATCH) { U32 i; for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];