]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add warning when multi-thread decompression is requested (#3208)
authorTom Wang <tomcwang@fb.com>
Fri, 29 Jul 2022 19:51:58 +0000 (12:51 -0700)
committerGitHub <noreply@github.com>
Fri, 29 Jul 2022 19:51:58 +0000 (12:51 -0700)
When user pass in argument for both decompression and multi-thread, print a warning message
to indicate that multi-threaded decompression is not supported.

* Add warning when multi-thread decompression is requested
* add test case for multi-threaded decoding warning
   Expectation is for -d -T0 we will not throw any warning,
   and see warning for any other -d -T(>1) inputs

programs/zstdcli.c
tests/cli-tests/compression/multi-threaded.sh
tests/cli-tests/compression/multi-threaded.sh.stderr.exact [new file with mode: 0644]

index fbacb908a9292d75af057c817283e56c61bd6e4a..372b7d7a30633f76849c5352161d84984824fcd3 100644 (file)
@@ -1226,6 +1226,9 @@ int main(int argCount, const char* argv[])
     DISPLAYLEVEL(3, WELCOME_MESSAGE);
 
 #ifdef ZSTD_MULTITHREAD
+    if ((operation==zom_decompress) && (!singleThread) && (nbWorkers > 1)) {
+        DISPLAYLEVEL(2, "Warning : decompression does not support multi-threading\n");
+    }
     if ((nbWorkers==0) && (!singleThread)) {
         /* automatically set # workers based on # of reported cpus */
         if (defaultLogicalCores) {
index e3961330a0a4f2bcccb198d95b106e98db9d289d..bd01448e2e84c26263272e9c7979ba95bedf7a35 100755 (executable)
@@ -9,3 +9,7 @@ zstd --rsyncable -f file                ; zstd -t file.zst
 zstd -T0 -f file                        ; zstd -t file.zst
 zstd -T0 --auto-threads=logical -f file ; zstd -t file.zst
 zstd -T0 --auto-threads=physical -f file; zstd -t file.zst
+
+# multi-thread decompression warning test
+zstd -T0 -f file                        ; zstd -t file.zst; zstd -T0 -d file.zst -o file3
+zstd -T0 -f file                        ; zstd -t file.zst; zstd -T2 -d file.zst -o file4
diff --git a/tests/cli-tests/compression/multi-threaded.sh.stderr.exact b/tests/cli-tests/compression/multi-threaded.sh.stderr.exact
new file mode 100644 (file)
index 0000000..54d47d8
--- /dev/null
@@ -0,0 +1 @@
+Warning : decompression does not support multi-threading