From 43161ba840cb290db38509f9a537e1550fbd8645 Mon Sep 17 00:00:00 2001 From: Sergey Dryabzhinsky Date: Thu, 6 Nov 2025 13:07:16 +0300 Subject: [PATCH 1/2] Update zstdcli.c New take on #4510, add new preprocessor var to always choose logical cores over physical --- programs/zstdcli.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 01760ff8c45..7ecb6e0a2e3 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -39,6 +39,10 @@ # define ZSTDCLI_CLEVEL_DEFAULT 3 #endif +#ifndef ZSTDCLI_AUTO_THREADING_LOGICAL +# define ZSTDCLI_AUTO_THREADING_LOGICAL 0 +#endif + #ifndef ZSTDCLI_CLEVEL_MAX # define ZSTDCLI_CLEVEL_MAX 19 /* without using --ultra */ #endif @@ -237,7 +241,7 @@ static void usageAdvanced(const char* programName) DISPLAYOUT(" -T# Spawn # compression threads. [Default: %u; pass 0 for core count.]\n", init_nbWorkers(ZSTDCLI_NBTHREADS_DEFAULT)); DISPLAYOUT(" --single-thread Share a single thread for I/O and compression (slightly different than `-T1`).\n"); DISPLAYOUT(" --auto-threads={physical|logical}\n"); - DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default: Physical]\n\n"); + DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default:"(ZSTDCLI_AUTO_THREADING_LOGICAL?"Logical":"Physical")" ]\n\n"); DISPLAYOUT(" --jobsize=# Set job size to #. [Default: 0 (automatic)]\n"); DISPLAYOUT(" --rsyncable Compress using a rsync-friendly method (`--jobsize=#` sets unit size). \n"); DISPLAYOUT("\n"); @@ -1113,6 +1117,9 @@ int main(int argCount, const char* argv[]) defaultLogicalCores = 1; continue; } +#ifdef ZSTDCLI_AUTO_THREADING_LOGICAL + defaultLogicalCores = 1; +#endif #ifdef UTIL_HAS_MIRRORFILELIST if (longCommandWArg(&argument, "--output-dir-mirror")) { NEXT_FIELD(outMirroredDirName); From bfd85e37ad00c2346ca1f8921b53f4d2a6f0cc09 Mon Sep 17 00:00:00 2001 From: Sergey Dryabzhinsky Date: Thu, 6 Nov 2025 13:21:37 +0300 Subject: [PATCH 2/2] Update zstdcli.c Simplify output construction --- programs/zstdcli.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 7ecb6e0a2e3..110ab892a29 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -241,7 +241,11 @@ static void usageAdvanced(const char* programName) DISPLAYOUT(" -T# Spawn # compression threads. [Default: %u; pass 0 for core count.]\n", init_nbWorkers(ZSTDCLI_NBTHREADS_DEFAULT)); DISPLAYOUT(" --single-thread Share a single thread for I/O and compression (slightly different than `-T1`).\n"); DISPLAYOUT(" --auto-threads={physical|logical}\n"); - DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default:"(ZSTDCLI_AUTO_THREADING_LOGICAL?"Logical":"Physical")" ]\n\n"); +#ifdef ZSTDCLI_AUTO_THREADING_LOGICAL + DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default: Logical ]\n\n"); +#else + DISPLAYOUT(" Use physical/logical cores when using `-T0`. [Default: Physical ]\n\n"); +#endif DISPLAYOUT(" --jobsize=# Set job size to #. [Default: 0 (automatic)]\n"); DISPLAYOUT(" --rsyncable Compress using a rsync-friendly method (`--jobsize=#` sets unit size). \n"); DISPLAYOUT("\n");