Repository navigation
perf: match upstream rsync compression negotiation precedence - #2737
Merged
Merged
Conversation
… lz4 > zlib)
Root cause: oc-rsync used zlib for all local transfers while upstream
rsync 3.4.1 negotiates zstd (5x faster). Three issues fixed:
1. Default compression algorithm hardcoded to Zlib instead of matching
upstream's compat.c:valid_compressions_items[] precedence order
(zstd > lz4 > zlibx > zlib > none).
2. Protocol crate never received zstd/lz4 feature flags - the feature
chain went root -> core -> {engine, transfer, compress} but skipped
protocol, so supported_compressions() never advertised zstd/lz4.
3. Switched default zlib backend from zlib-rs (pure Rust) to zlib-ng
(C library with SIMD: SSE2, AVX2, NEON) for when zlib is needed
with older peers, matching upstream rsync's zlib performance.
Container benchmark (157MB, 10K files, aarch64):
Before: upstream 550ms, oc-rsync 1550ms (3.2x slower)
After: upstream 550ms, oc-rsync 635ms (1.15x)
Tests that explicitly set CompressionAlgorithm::Zstd now use Zlib instead, since zstd is the new default and --compress-choice is only emitted for non-default algorithms.
The bandwidth limiting test verifies post-compression byte counting, not compression algorithm selection. Pin to Zlib so the test is not sensitive to the default algorithm changing from zlib to zstd.
The zstd wire protocol uses per-token flushing (ZSTD_e_flush) in upstream token.c, while oc-rsync uses stream-level compression. Until the wire framing is compatible, do not propagate zstd/lz4 features to the protocol crate - this prevents advertising them in compression negotiation. Local transfers still use zstd via the compress crate directly.
oferchen
added a commit
that referenced
this pull request
May 1, 2026
* perf: match upstream rsync compression negotiation precedence (zstd > lz4 > zlib)
Root cause: oc-rsync used zlib for all local transfers while upstream
rsync 3.4.1 negotiates zstd (5x faster). Three issues fixed:
1. Default compression algorithm hardcoded to Zlib instead of matching
upstream's compat.c:valid_compressions_items[] precedence order
(zstd > lz4 > zlibx > zlib > none).
2. Protocol crate never received zstd/lz4 feature flags - the feature
chain went root -> core -> {engine, transfer, compress} but skipped
protocol, so supported_compressions() never advertised zstd/lz4.
3. Switched default zlib backend from zlib-rs (pure Rust) to zlib-ng
(C library with SIMD: SSE2, AVX2, NEON) for when zlib is needed
with older peers, matching upstream rsync's zlib performance.
Container benchmark (157MB, 10K files, aarch64):
Before: upstream 550ms, oc-rsync 1550ms (3.2x slower)
After: upstream 550ms, oc-rsync 635ms (1.15x)
* fix: update tests for zstd default compression algorithm
Tests that explicitly set CompressionAlgorithm::Zstd now use Zlib
instead, since zstd is the new default and --compress-choice is only
emitted for non-default algorithms.
* fix: use explicit Zlib in bandwidth compression test
The bandwidth limiting test verifies post-compression byte counting,
not compression algorithm selection. Pin to Zlib so the test is not
sensitive to the default algorithm changing from zlib to zstd.
* fix: do not advertise zstd/lz4 in protocol negotiation
The zstd wire protocol uses per-token flushing (ZSTD_e_flush) in
upstream token.c, while oc-rsync uses stream-level compression.
Until the wire framing is compatible, do not propagate zstd/lz4
features to the protocol crate - this prevents advertising them
in compression negotiation. Local transfers still use zstd via
the compress crate directly.
oferchen
added a commit
that referenced
this pull request
May 5, 2026
* perf: match upstream rsync compression negotiation precedence (zstd > lz4 > zlib)
Root cause: oc-rsync used zlib for all local transfers while upstream
rsync 3.4.1 negotiates zstd (5x faster). Three issues fixed:
1. Default compression algorithm hardcoded to Zlib instead of matching
upstream's compat.c:valid_compressions_items[] precedence order
(zstd > lz4 > zlibx > zlib > none).
2. Protocol crate never received zstd/lz4 feature flags - the feature
chain went root -> core -> {engine, transfer, compress} but skipped
protocol, so supported_compressions() never advertised zstd/lz4.
3. Switched default zlib backend from zlib-rs (pure Rust) to zlib-ng
(C library with SIMD: SSE2, AVX2, NEON) for when zlib is needed
with older peers, matching upstream rsync's zlib performance.
Container benchmark (157MB, 10K files, aarch64):
Before: upstream 550ms, oc-rsync 1550ms (3.2x slower)
After: upstream 550ms, oc-rsync 635ms (1.15x)
* fix: update tests for zstd default compression algorithm
Tests that explicitly set CompressionAlgorithm::Zstd now use Zlib
instead, since zstd is the new default and --compress-choice is only
emitted for non-default algorithms.
* fix: use explicit Zlib in bandwidth compression test
The bandwidth limiting test verifies post-compression byte counting,
not compression algorithm selection. Pin to Zlib so the test is not
sensitive to the default algorithm changing from zlib to zstd.
* fix: do not advertise zstd/lz4 in protocol negotiation
The zstd wire protocol uses per-token flushing (ZSTD_e_flush) in
upstream token.c, while oc-rsync uses stream-level compression.
Until the wire framing is compatible, do not propagate zstd/lz4
features to the protocol crate - this prevents advertising them
in compression negotiation. Local transfers still use zstd via
the compress crate directly.
This was referenced May 23, 2026
Merged
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
compat.c:valid_compressions_items[]precedence: zstd > lz4 > zlibx > zlib > noneRoot cause: Local transfers hardcoded
CompressionAlgorithm::Zlibwhile upstream rsync 3.4.1 negotiates zstd (confirmed via perf profiling: upstream showsZSTD_compressStream2, oc-rsync showeddeflate_medium/zng_deflate). Upstream with explicit--compress-choice=zlibtakes 1457ms, proving the backends are equivalent - only the algorithm selection differed.Benchmark (container, 157MB, 10K files, aarch64)
-a(no compress)-az(compress)Test plan
--compress-choice=zlibstill works for explicit zlib selection