From: Yann Collet Date: Thu, 13 Jul 2017 17:10:13 +0000 (-0700) Subject: policy change : ZSTDMT automatically caps nbThreads to ZSTDMT_NBTHREADS_MAX (#760) X-Git-Tag: v1.3.1^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a60efd3a92ce2e3b222e69ff0965a223d26978e;p=thirdparty%2Fzstd.git policy change : ZSTDMT automatically caps nbThreads to ZSTDMT_NBTHREADS_MAX (#760) Previously, ZSTDMT would refuse to create the compressor. Also : increased ZSTDMT_NBTHREADS_MAX to 256, updated doc, and added relevant test --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index ed4b9117a..3be850c6d 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -9,7 +9,7 @@ /* ====== Tuning parameters ====== */ -#define ZSTDMT_NBTHREADS_MAX 128 +#define ZSTDMT_NBTHREADS_MAX 256 #define ZSTDMT_OVERLAPLOG_DEFAULT 6 @@ -407,7 +407,8 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem) U32 nbJobs = nbThreads + 2; DEBUGLOG(3, "ZSTDMT_createCCtx_advanced"); - if ((nbThreads < 1) | (nbThreads > ZSTDMT_NBTHREADS_MAX)) return NULL; + if (nbThreads < 1) return NULL; + nbThreads = MIN(nbThreads , ZSTDMT_NBTHREADS_MAX); if ((cMem.customAlloc!=NULL) ^ (cMem.customFree!=NULL)) /* invalid custom allocator */ return NULL; diff --git a/programs/zstd.1 b/programs/zstd.1 index 5df45db21..2b80659cc 100644 --- a/programs/zstd.1 +++ b/programs/zstd.1 @@ -1,5 +1,5 @@ . -.TH "ZSTD" "1" "June 2017" "zstd 1.3.0" "User Commands" +.TH "ZSTD" "1" "July 2017" "zstd 1.3.1" "User Commands" . .SH "NAME" \fBzstd\fR \- zstd, zstdmt, unzstd, zstdcat \- Compress or decompress \.zst files @@ -105,7 +105,7 @@ unlocks high compression levels 20+ (maximum 22), using a lot more memory\. Note . .TP \fB\-T#\fR, \fB\-\-threads=#\fR -Compress using \fB#\fR threads (default: 1)\. If \fB#\fR is 0, attempt to detect and use the number of physical CPU cores\. This modifier does nothing if \fBzstd\fR is compiled without multithread support\. +Compress using \fB#\fR threads (default: 1)\. If \fB#\fR is 0, attempt to detect and use the number of physical CPU cores\. In all cases, the nb of threads is capped to ZSTDMT_NBTHREADS_MAX==256\. This modifier does nothing if \fBzstd\fR is compiled without multithread support\. . .TP \fB\-D file\fR diff --git a/programs/zstd.1.md b/programs/zstd.1.md index 24e25a2f3..ba51c8435 100644 --- a/programs/zstd.1.md +++ b/programs/zstd.1.md @@ -108,6 +108,7 @@ the last one takes effect. * `-T#`, `--threads=#`: Compress using `#` threads (default: 1). If `#` is 0, attempt to detect and use the number of physical CPU cores. + In all cases, the nb of threads is capped to ZSTDMT_NBTHREADS_MAX==256. This modifier does nothing if `zstd` is compiled without multithread support. * `-D file`: use `file` as Dictionary to compress or decompress FILE(s) diff --git a/tests/playTests.sh b/tests/playTests.sh index 88a1c2ab4..dd0f2dbfe 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -643,7 +643,8 @@ then $ECHO "\n**** zstdmt long round-trip tests **** " roundTripTest -g99000000 -P99 "20 -T2" roundTripTest -g6000000000 -P99 "1 -T2" - fileRoundTripTest -g4193M -P98 " -T0" + roundTripTest -g1500000000 -P97 "1 -T999" + fileRoundTripTest -g4195M -P98 " -T0" else $ECHO "\n**** no multithreading, skipping zstdmt tests **** " fi