Skip to content

feat(cli): add --rayon-threads and --tokio-threads tunables#3747

Merged
oferchen merged 2 commits into
masterfrom
feat/thread-count-cli-flags
May 6, 2026
Merged

feat(cli): add --rayon-threads and --tokio-threads tunables#3747
oferchen merged 2 commits into
masterfrom
feat/thread-count-cli-flags

Conversation

@oferchen
Copy link
Copy Markdown
Owner

@oferchen oferchen commented May 5, 2026

Summary

  • Adds --rayon-threads=N and --tokio-threads=N CLI tunables (1-1024) for capping the local rayon worker pool and async tokio runtime worker count.
  • --rayon-threads calls rayon::ThreadPoolBuilder::build_global() at the top of the execute path before any rayon work begins; failure to install (e.g. pool already initialised) is reported as a non-fatal warning so transfers continue with the default thread count.
  • --tokio-threads is plumbed through ParsedArgs -> ConfigInputs -> ClientConfigBuilder -> ClientConfig so async transports (gated behind the async feature) can honour the cap when they are constructed.
  • Validation rejects 0 and values exceeding 1024; non-numeric input is rejected with the offending token quoted in the error.
  • Both flags are local-only and intentionally not forwarded to the remote peer.

Test plan

  • cargo nextest run -p cli --all-features -E 'test(rayon_threads) | test(tokio_threads)'
  • cargo nextest run -p core --all-features -E 'test(rayon_threads) | test(tokio_threads)'
  • CI green on fmt+clippy, nextest (stable), Windows, macOS, Linux musl

@github-actions github-actions Bot added the enhancement New feature or request label May 5, 2026
oferchen added 2 commits May 6, 2026 12:23
Expose two new local-only worker pool tunables on the CLI:

- --rayon-threads=N caps rayon's global pool, applied via
  ThreadPoolBuilder::build_global() before any rayon work begins.
- --tokio-threads=N is plumbed through ClientConfig so async
  transports (gated behind the async feature) can honour it.

Both flags reject 0 and values exceeding 1024. Values flow from
ParsedArgs through ConfigInputs into ClientConfig, with NonZeroUsize
storage on the config side. Local-only - neither flag is forwarded
to the remote peer.
@oferchen oferchen force-pushed the feat/thread-count-cli-flags branch from 6b21001 to 9e45503 Compare May 6, 2026 09:23
@oferchen oferchen merged commit 72d56b0 into master May 6, 2026
40 checks passed
@oferchen oferchen deleted the feat/thread-count-cli-flags branch May 6, 2026 18:55
oferchen added a commit that referenced this pull request May 18, 2026
* feat(cli): add --rayon-threads and --tokio-threads tunables

Expose two new local-only worker pool tunables on the CLI:

- --rayon-threads=N caps rayon's global pool, applied via
  ThreadPoolBuilder::build_global() before any rayon work begins.
- --tokio-threads=N is plumbed through ClientConfig so async
  transports (gated behind the async feature) can honour it.

Both flags reject 0 and values exceeding 1024. Values flow from
ParsedArgs through ConfigInputs into ClientConfig, with NonZeroUsize
storage on the config side. Local-only - neither flag is forwarded
to the remote peer.

* fix(deps): regenerate Cargo.lock for rayon workspace dep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant