feat: wire --compress-threads=N through to zstd ZSTD_c_nbWorkers (3.4.2 parity)#4100
Merged
Merged
Conversation
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #4095 added
--compress-threads=Nparsing and stored the value inClientConfig::compression_threads, but nothing actually consumed it.This change wires the value through to the zstd encoder so the flag
takes effect.
compress::zstd::CountingZstdEncodergainsnew_with_workers/with_sink_workersconstructors that callmultithread(n)(i.e.ZSTD_c_nbWorkers). A newSUPPORTS_MULTITHREADconstant exposeswhether the build has the underlying C support compiled in.
engine::ActiveCompressor::new_with_workersandtransfer::CompressedWriter::with_workerspropagate the valueend-to-end.
LocalCopyOptionsgainscompression_threads, populatedfrom
ClientConfig::compression_threadsinapply_compression.zstdmtCargo feature on thecompresscrate (off by default to keep minimal builds lean andavoid a forced C build cost). Requesting workers without the
feature returns
io::ErrorKind::Unsupported, so callers fail loudlyinstead 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
Noneand verifiesSome(_)either compresses orsurfaces
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.