]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
policy change : ZSTDMT automatically caps nbThreads to ZSTDMT_NBTHREADS_MAX (#760)
authorYann Collet <cyan@fb.com>
Thu, 13 Jul 2017 17:10:13 +0000 (10:10 -0700)
committerYann Collet <cyan@fb.com>
Thu, 13 Jul 2017 17:17:23 +0000 (10:17 -0700)
Previously, ZSTDMT would refuse to create the compressor.
Also : increased ZSTDMT_NBTHREADS_MAX to 256,
updated doc,
and added relevant test

lib/compress/zstdmt_compress.c
programs/zstd.1
programs/zstd.1.md
tests/playTests.sh

index ed4b9117a27372c10f5ea729d91b34fb14a6bfcb..3be850c6d5092d206231f76772beef11a1a064f3 100644 (file)
@@ -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;
index 5df45db2153ecb36458ba43277a7abd8909c6094..2b80659cc8f8401251d05c280ba07af56753fe27 100644 (file)
@@ -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
index 24e25a2f3af1ba42c251c1898409b65d57d5cb61..ba51c8435e26427a9de0d5553c012be0209c7bac 100644 (file)
@@ -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)
index 88a1c2ab4cb4354440f51f6296fba5ac87ebd124..dd0f2dbfea5329c16e6d8b7fae3891bf744d5eb4 100755 (executable)
@@ -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