From d4a5bc4efc40e090bf55a1a9221b6ab26b17b302 Mon Sep 17 00:00:00 2001 From: Tom Wang Date: Fri, 29 Jul 2022 12:51:58 -0700 Subject: [PATCH] Add warning when multi-thread decompression is requested (#3208) 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 | 3 +++ tests/cli-tests/compression/multi-threaded.sh | 4 ++++ tests/cli-tests/compression/multi-threaded.sh.stderr.exact | 1 + 3 files changed, 8 insertions(+) create mode 100644 tests/cli-tests/compression/multi-threaded.sh.stderr.exact diff --git a/programs/zstdcli.c b/programs/zstdcli.c index fbacb908a..372b7d7a3 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -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) { diff --git a/tests/cli-tests/compression/multi-threaded.sh b/tests/cli-tests/compression/multi-threaded.sh index e3961330a..bd01448e2 100755 --- a/tests/cli-tests/compression/multi-threaded.sh +++ b/tests/cli-tests/compression/multi-threaded.sh @@ -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 index 000000000..54d47d8bd --- /dev/null +++ b/tests/cli-tests/compression/multi-threaded.sh.stderr.exact @@ -0,0 +1 @@ +Warning : decompression does not support multi-threading