Skip to content

feat: wire --compress-threads=N through to zstd ZSTD_c_nbWorkers (3.4.2 parity)#4100

Merged
oferchen merged 6 commits into
masterfrom
feat/compress-threads-zstd-wiring-2239
May 15, 2026
Merged

feat: wire --compress-threads=N through to zstd ZSTD_c_nbWorkers (3.4.2 parity)#4100
oferchen merged 6 commits into
masterfrom
feat/compress-threads-zstd-wiring-2239

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

PR #4095 added --compress-threads=N parsing and stored the value in
ClientConfig::compression_threads, but nothing actually consumed it.
This change wires the value through to the zstd encoder so the flag
takes effect.

  • compress::zstd::CountingZstdEncoder gains new_with_workers /
    with_sink_workers constructors that call multithread(n) (i.e.
    ZSTD_c_nbWorkers). A new SUPPORTS_MULTITHREAD constant exposes
    whether the build has the underlying C support compiled in.
  • engine::ActiveCompressor::new_with_workers and
    transfer::CompressedWriter::with_workers propagate the value
    end-to-end. LocalCopyOptions gains compression_threads, populated
    from ClientConfig::compression_threads in apply_compression.
  • Multithreaded zstd lives behind a zstdmt Cargo feature on the
    compress crate (off by default to keep minimal builds lean and
    avoid a forced C build cost). Requesting workers without the
    feature returns io::ErrorKind::Unsupported, so callers fail loudly
    instead of silently discarding the user's setting.

Mirrors upstream:

  • options.c:89 - do_compression_threads = 0 (single-threaded default).
  • token.c:701 - ZSTD_CCtx_setParameter(zstd_cctx, ZSTD_c_nbWorkers, do_compression_threads).

Refs #2239, parent #2217.

Test plan

  • compress::zstd::workers_path_round_trip_and_smoke -
    round-trips None and verifies Some(_) either compresses or
    surfaces Unsupported.
  • engine::compressor::active_compressor_zstd_workers_dispatches_to_encoder -
    same dispatch contract at the engine layer.
  • transfer::compressed_writer::zstd_tests::with_workers_round_trip_and_smoke -
    end-to-end through the multiplexed writer.
  • engine::options::compression::with_compression_threads_round_trips -
    builder round-trip for the new option field.
  • CI green (fmt+clippy, nextest stable, Windows, macOS, Linux musl).

Plumb the value parsed in #4095 into the actual zstd encoder via
`ZSTD_c_nbWorkers`, matching upstream `token.c:701` so a non-zero
`--compress-threads=N` engages real worker threads instead of being
silently dropped.

- `compress::zstd::CountingZstdEncoder` gains `new_with_workers` /
  `with_sink_workers` constructors and a `SUPPORTS_MULTITHREAD` const.
- `engine::ActiveCompressor::new_with_workers` and
  `transfer::CompressedWriter::with_workers` thread the value end to
  end. `LocalCopyOptions` gains `compression_threads` and is populated
  from `ClientConfig::compression_threads` in `apply_compression`.
- Multithreaded zstd lives behind a `zstdmt` Cargo feature on the
  `compress` crate (off by default to avoid a forced C build cost).
  Requesting workers without the feature returns `Unsupported` so
  callers can fall back to single-threaded compression instead of
  silently discarding the user's request.

upstream: options.c:89 do_compression_threads, token.c:701.

Refs #2239, #2217.
@github-actions github-actions Bot added the enhancement New feature or request label May 15, 2026
@oferchen oferchen merged commit 3567fe2 into master May 15, 2026
40 checks passed
@oferchen oferchen deleted the feat/compress-threads-zstd-wiring-2239 branch May 16, 2026 19:50
oferchen added a commit that referenced this pull request May 18, 2026
….2 parity) (#4100)

* feat: wire --compress-threads=N through to zstd ZSTD_c_nbWorkers

Plumb the value parsed in #4095 into the actual zstd encoder via
`ZSTD_c_nbWorkers`, matching upstream `token.c:701` so a non-zero
`--compress-threads=N` engages real worker threads instead of being
silently dropped.

- `compress::zstd::CountingZstdEncoder` gains `new_with_workers` /
  `with_sink_workers` constructors and a `SUPPORTS_MULTITHREAD` const.
- `engine::ActiveCompressor::new_with_workers` and
  `transfer::CompressedWriter::with_workers` thread the value end to
  end. `LocalCopyOptions` gains `compression_threads` and is populated
  from `ClientConfig::compression_threads` in `apply_compression`.
- Multithreaded zstd lives behind a `zstdmt` Cargo feature on the
  `compress` crate (off by default to avoid a forced C build cost).
  Requesting workers without the feature returns `Unsupported` so
  callers can fall back to single-threaded compression instead of
  silently discarding the user's request.

upstream: options.c:89 do_compression_threads, token.c:701.

Refs #2239, #2217.

* style: apply rustfmt to zstd worker wiring

* fix(compress): avoid Result::unwrap_err since encoder lacks Debug

* fix(engine): wire compression_threads through options builder + Debug-safe unwrap

* fix(engine): gate unused ActiveCompressor::new behind #[cfg(test)]

* fix(transfer): avoid expect_err on CompressedWriter lacking Debug
oferchen added a commit that referenced this pull request May 18, 2026
….2 parity) (#4100)

* feat: wire --compress-threads=N through to zstd ZSTD_c_nbWorkers

Plumb the value parsed in #4095 into the actual zstd encoder via
`ZSTD_c_nbWorkers`, matching upstream `token.c:701` so a non-zero
`--compress-threads=N` engages real worker threads instead of being
silently dropped.

- `compress::zstd::CountingZstdEncoder` gains `new_with_workers` /
  `with_sink_workers` constructors and a `SUPPORTS_MULTITHREAD` const.
- `engine::ActiveCompressor::new_with_workers` and
  `transfer::CompressedWriter::with_workers` thread the value end to
  end. `LocalCopyOptions` gains `compression_threads` and is populated
  from `ClientConfig::compression_threads` in `apply_compression`.
- Multithreaded zstd lives behind a `zstdmt` Cargo feature on the
  `compress` crate (off by default to avoid a forced C build cost).
  Requesting workers without the feature returns `Unsupported` so
  callers can fall back to single-threaded compression instead of
  silently discarding the user's request.

upstream: options.c:89 do_compression_threads, token.c:701.

Refs #2239, #2217.

* style: apply rustfmt to zstd worker wiring

* fix(compress): avoid Result::unwrap_err since encoder lacks Debug

* fix(engine): wire compression_threads through options builder + Debug-safe unwrap

* fix(engine): gate unused ActiveCompressor::new behind #[cfg(test)]

* fix(transfer): avoid expect_err on CompressedWriter lacking Debug
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