Skip to content

man: fix default thread counts for -T#, ZSTD_NBTHREADS and benchmark mode - #4847

Open
fjvbn2003 wants to merge 1 commit into
meta:devfrom
fjvbn2003:man-default-threads
Open

fjvbn2003 wants to merge 1 commit into
meta:devfrom
fjvbn2003:man-default-threads

Conversation

@fjvbn2003

Copy link
Copy Markdown

What and why

Three statements about default thread counts in programs/zstd.1.md (and the generated programs/zstd.1) no longer match the code on dev:

  1. -T# says the default is "between 1 and 4 depending on physical CPU cores". The default is ZSTDCLI_NBTHREADS_DEFAULT, which is MAX(1, MIN(4, UTIL_countLogicalCores() / 4)) (programs/zstdcli.c, introduced in Change CLI to employ multithreading by default #4211). On an 8-core/16-thread machine this gives 4 threads, not 2. (Only -T0 uses physical cores by default, via --auto-threads=physical, and the man page already says so.)
  2. The ZSTD_NBTHREADS paragraph says the value "is capped at ZSTDMT_NBWORKERS_MAX==200". ZSTDMT_NBWORKERS_MAX is 64 on 32-bit and 256 on 64-bit (lib/compress/zstdmt_compress.h), which is also what the -T# paragraph of the same page says.
  3. The benchmark section says benchmarking uses max(1, min(4, nbCores/4)) worker threads by default. Since 725a152 ("benchmark uses 1 thread by default"), zstdcli.c sets nbWorkers = 1 in bench mode when -T# is not given. (v1.5.7 still used the formula, so this only affects the next release.)

This PR updates the three sentences in zstd.1.md and the matching lines in zstd.1, in the same way #4474 did.

How I checked: I read programs/zstdcli.c and lib/compress/zstdmt_compress.h on dev, and found the commits through git log. With zstd v1.5.7 on a 10-core machine, zstd -vvvv reports Compressing with 2 worker threads (10/4 = 2) and -b1 reports using 2 threads, which matches the v1.5.7 code. I did not build dev. On this machine the physical and logical core counts are both 10, so the physical/logical difference in point 1 comes from reading the source, not from a run.

Checklist

  • I searched open pull requests and issues: this problem is not already being addressed (Manual and error message improvements #4521 is about other parts of the manual).
  • Bug fix: it comes with a reproducer or a test that fails without the fix. (Documentation only.)
  • Performance change: n/a

Tools used

An AI assistant (Claude) helped compare the man page with the source and draft the wording. I reviewed and checked every change against the code.

🤖 Generated with Claude Code

…mode

- -T# default is ZSTDCLI_NBTHREADS_DEFAULT, based on logical cores
  (UTIL_countLogicalCores() / 4, since meta#4211), not physical cores.
- ZSTDMT_NBWORKERS_MAX is 64 on 32-bit and 256 on 64-bit, not 200.
- Benchmark mode uses 1 worker thread by default since 725a152.

Signed-off-by: YoungjuKim <fjvbn2003@gmail.com>
@meta-cla meta-cla Bot added the CLA Signed label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant