]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
specify new command --single-thread
authorYann Collet <cyan@fb.com>
Fri, 9 Feb 2018 23:53:27 +0000 (15:53 -0800)
committerYann Collet <cyan@fb.com>
Fri, 9 Feb 2018 23:55:41 +0000 (15:55 -0800)
programs/fileio.c
programs/zstd.1.md
programs/zstdcli.c
tests/playTests.sh

index 0cc807a110c44fa130c7593d1222d2a4bda1c456..d344b8f69e5172f60f2b5f90db253a1db781acef 100644 (file)
@@ -461,7 +461,7 @@ static cRess_t FIO_createCResources(const char* dictFileName, int cLevel,
         CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_p_compressionStrategy, (U32)comprParams->strategy) );
         /* multi-threading */
 #ifdef ZSTD_MULTITHREAD
-        DISPLAYLEVEL(5,"set nb threads = %u \n", g_nbWorkers);
+        DISPLAYLEVEL(5,"set nb workers = %u \n", g_nbWorkers);
         CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_p_nbWorkers, g_nbWorkers) );
 #endif
         /* dictionary */
index 4d9ec2fce8cbd3c848fcc4a1ead2cf22ef4e28eb..c970c5cbbda1d12d28bd0c6829bade278d72e280 100644 (file)
@@ -116,10 +116,16 @@ the last one takes effect.
     Note: If `windowLog` is set to larger than 27, `--long=windowLog` or
     `--memory=windowSize` needs to be passed to the decompressor.
 * `-T#`, `--threads=#`:
-    Compress using `#` threads (default: 1).
+    Compress using `#` working 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.
+    In all cases, the nb of threads is capped to ZSTDMT_NBTHREADS_MAX==200.
     This modifier does nothing if `zstd` is compiled without multithread support.
+* `--single-thread`:
+    Does not spawn a thread for compression, use caller thread instead.
+    This is the only available mode when multithread support is disabled.
+    In this mode, compression is serialized with I/O.
+    (This is different from `-T1`, which spawns 1 compression thread in parallel of I/O).
+    Single-thread mode also features lower memory usage.
 * `-D file`:
     use `file` as Dictionary to compress or decompress FILE(s)
 * `--nodictID`:
index 015dc5e4c77a1c2626322a3176e20253896cb96a..6d7957c804a853bdd93174aa169a52926c496781 100644 (file)
@@ -135,7 +135,7 @@ static int usage_advanced(const char* programName)
     DISPLAY( "--ultra : enable levels beyond %i, up to %i (requires more memory)\n", ZSTDCLI_CLEVEL_MAX, ZSTD_maxCLevel());
     DISPLAY( "--long[=#]  : enable long distance matching with given window log (default: %u)\n", g_defaultMaxWindowLog);
 #ifdef ZSTD_MULTITHREAD
-    DISPLAY( " -T#    : use # threads for compression (default: 1) \n");
+    DISPLAY( " -T#    : spawns # compression threads (default: 1) \n");
     DISPLAY( " -B#    : select size of each job (default: 0==automatic) \n");
 #endif
     DISPLAY( "--no-dictID : don't write dictID into header (dictionary compression)\n");
@@ -366,21 +366,21 @@ typedef enum { zom_compress, zom_decompress, zom_test, zom_bench, zom_train, zom
 int main(int argCount, const char* argv[])
 {
     int argNb,
-        forceStdout=0,
         followLinks=0,
+        forceStdout=0,
+        lastCommand = 0,
+        ldmFlag = 0,
         main_pause=0,
-        nextEntryIsDictionary=0,
-        operationResult=0,
+        nbWorkers = 1,
         nextArgumentIsOutFileName=0,
         nextArgumentIsMaxDict=0,
         nextArgumentIsDictID=0,
         nextArgumentsAreFiles=0,
-        ultra=0,
-        lastCommand = 0,
-        nbWorkers = 1,
-        setRealTimePrio = 0,
+        nextEntryIsDictionary=0,
+        operationResult=0,
         separateFiles = 0,
-        ldmFlag = 0;
+        setRealTimePrio = 0,
+        ultra=0;
     unsigned bench_nbSeconds = 3;   /* would be better if this value was synchronized from bench */
     size_t blockSize = 0;
     zstd_operation_mode operation = zom_compress;
@@ -481,6 +481,7 @@ int main(int argCount, const char* argv[])
                     if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(0); continue; }
                     if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; }
                     if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; }
+                    if (!strcmp(argument, "--single-thread")) { nbWorkers = 0; continue; }
 #ifdef ZSTD_GZCOMPRESS
                     if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; FIO_setCompressionType(FIO_gzipCompression); continue; }
 #endif
index 0e12ec8e71d5d5aa95aa3ba422e11705ca9d84d1..258c9c75bef483cd91203b3140d7ec7aa2992c39 100755 (executable)
@@ -634,6 +634,7 @@ roundTripTest -g518K "19 --long"
 fileRoundTripTest -g5M "3 --long"
 
 
+roundTripTest -g96K "5 --single-thread"
 if [ -n "$hasMT" ]
 then
     $ECHO "\n===>  zstdmt round-trip tests "