From: Yann Collet Date: Mon, 23 Jan 2017 08:56:54 +0000 (-0800) Subject: ZSTDMT_compressCCtx : fallback to single-thread mode when nbChunks==1 X-Git-Tag: v1.1.3^2~19^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84581ff8d7cb7bcd18091c6bfada1764baa3c206;p=thirdparty%2Fzstd.git ZSTDMT_compressCCtx : fallback to single-thread mode when nbChunks==1 --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 176f940c8..18ed74417 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -360,6 +360,15 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx, DEBUGLOG(2, "nbChunks : %2u (chunkSize : %u bytes) ", nbChunks, (U32)avgChunkSize); params.fParams.contentSizeFlag = 1; + if (nbChunks==1) { /* fallback to single-thread mode */ + size_t result; + ZSTD_CCtx* const cctx = ZSTDMT_getCCtx(mtctx->cctxPool); + if (!cctx) return ERROR(memory_allocation); + result = ZSTD_compressCCtx(mtctx->cctxPool->cctx[0], dst, dstCapacity, src, srcSize, compressionLevel); + ZSTDMT_releaseCCtx(mtctx->cctxPool, cctx); + return result; + } + { unsigned u; for (u=0; udoneJobID < zcs->nextJobID) { unsigned const jobID = zcs->doneJobID & zcs->jobIDMask; @@ -708,6 +715,3 @@ size_t ZSTDMT_endStream(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output) { return ZSTDMT_flushStream_internal(zcs, output, 1); } - - -#endif