Skip to content

fix(protocol): separate preserve_devices and preserve_specials flags - #2507

Merged
oferchen merged 1 commit into
masterfrom
fix/separate-devices-specials
Feb 27, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/separate-devices-specials

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Split combined preserve_devices flag into separate preserve_devices and preserve_specials flags
  • Update FileListWriter/FileListReader with separate builder methods for each flag
  • Update flist batched_writer, receiver, and device encoding tests
  • Upstream rsync tracks these independently: -D enables both, but --devices and --specials can be used individually

Test plan

  • Verify cargo fmt --all -- --check passes
  • Verify cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings passes
  • Verify cargo nextest run --workspace --all-features passes
  • Verify device/special file handling matches upstream for --devices, --specials, and -D

@github-actions github-actions Bot added the bug Something isn't working label Feb 27, 2026
- Split combined preserve_devices flag into separate preserve_devices
  and preserve_specials flags to match upstream rsync behavior
- Update FileListWriter/FileListReader with separate builder methods
- Update flist batched_writer, receiver, and device encoding tests
- Upstream rsync tracks these independently for -D (--devices
  --specials) vs individual --devices or --specials flags
@oferchen
oferchen force-pushed the fix/separate-devices-specials branch from 5442587 to ba86b16 Compare February 27, 2026 03:37
@oferchen
oferchen merged commit 078169f into master Feb 27, 2026
7 checks passed
@oferchen
oferchen deleted the fix/separate-devices-specials branch February 27, 2026 09:46
oferchen added a commit that referenced this pull request May 1, 2026
fix(protocol): separate preserve_devices and preserve_specials flags
oferchen added a commit that referenced this pull request May 5, 2026
fix(protocol): separate preserve_devices and preserve_specials flags
oferchen added a commit that referenced this pull request May 21, 2026
BR-3j.a (PR #4600) selected DashMap to replace the outer
`Mutex<HashMap<FileNdx, Arc<Mutex<FileSlot>>>>` map in
`ParallelDeltaApplier`. The outer mutex serialised every per-chunk slot
lookup behind a single global lock, defeating the per-file fanout the
rest of the applier was built around (#2503, BR-3j.c).

This commit performs the source migration:

- `files: Mutex<HashMap<...>>` -> `files: DashMap<FileNdx, Arc<Mutex<FileSlot>>>`
- `register_file` uses `Entry::Vacant`/`Entry::Occupied` and pre-builds
  the slot Arc outside the shard guard so the reorder-buffer allocation
  never widens the lock window.
- `slot_for` clones the Arc and drops the shard read guard at the end
  of the expression; callers never see the DashMap guard, so they
  cannot accidentally hold it across the per-file mutex lock or a
  rayon dispatch.
- `finish_file` uses `DashMap::remove` which returns the owned `(K, V)`
  and drops the shard guard before `Arc::try_unwrap`.
- `Debug` reads `self.files.len()` directly.

The inner `Mutex<FileSlot>` is preserved: it remains the sole gate for
per-file writes so submission order is still enforced through the
`ReorderBuffer`. Public API of `ParallelDeltaApplier` is unchanged.

Adds a concurrency stress test
(`crates/engine/tests/parallel_apply_concurrent.rs`, BR-3j.e #2507)
that spawns N rayon workers each picking a random FileNdx from a pool
of 1000 files and verifies bytes_written matches expected. A second
test races registration and dispatch on overlapping files and asserts
the applier surfaces only typed errors (never panics or corrupts).
On the dev box the stress test reports ~2.17M ops/sec (8 workers,
1000 files, 10000 ops).

No unsafe code added. No clippy waivers. `cargo build -p engine
--no-default-features` still compiles. Targeted nextest runs for
`concurrent_delta` and `parallel_apply` binaries all pass (340 tests
including the 2 new stress tests).
oferchen added a commit that referenced this pull request May 21, 2026
…ap (#4634)

BR-3j.a (PR #4600) selected DashMap to replace the outer
`Mutex<HashMap<FileNdx, Arc<Mutex<FileSlot>>>>` map in
`ParallelDeltaApplier`. The outer mutex serialised every per-chunk slot
lookup behind a single global lock, defeating the per-file fanout the
rest of the applier was built around (#2503, BR-3j.c).

This commit performs the source migration:

- `files: Mutex<HashMap<...>>` -> `files: DashMap<FileNdx, Arc<Mutex<FileSlot>>>`
- `register_file` uses `Entry::Vacant`/`Entry::Occupied` and pre-builds
  the slot Arc outside the shard guard so the reorder-buffer allocation
  never widens the lock window.
- `slot_for` clones the Arc and drops the shard read guard at the end
  of the expression; callers never see the DashMap guard, so they
  cannot accidentally hold it across the per-file mutex lock or a
  rayon dispatch.
- `finish_file` uses `DashMap::remove` which returns the owned `(K, V)`
  and drops the shard guard before `Arc::try_unwrap`.
- `Debug` reads `self.files.len()` directly.

The inner `Mutex<FileSlot>` is preserved: it remains the sole gate for
per-file writes so submission order is still enforced through the
`ReorderBuffer`. Public API of `ParallelDeltaApplier` is unchanged.

Adds a concurrency stress test
(`crates/engine/tests/parallel_apply_concurrent.rs`, BR-3j.e #2507)
that spawns N rayon workers each picking a random FileNdx from a pool
of 1000 files and verifies bytes_written matches expected. A second
test races registration and dispatch on overlapping files and asserts
the applier surfaces only typed errors (never panics or corrupts).
On the dev box the stress test reports ~2.17M ops/sec (8 workers,
1000 files, 10000 ops).

No unsafe code added. No clippy waivers. `cargo build -p engine
--no-default-features` still compiles. Targeted nextest runs for
`concurrent_delta` and `parallel_apply` binaries all pass (340 tests
including the 2 new stress tests).
oferchen added a commit that referenced this pull request Aug 24, 2026
…ap (#4634)

BR-3j.a (PR #4600) selected DashMap to replace the outer
`Mutex<HashMap<FileNdx, Arc<Mutex<FileSlot>>>>` map in
`ParallelDeltaApplier`. The outer mutex serialised every per-chunk slot
lookup behind a single global lock, defeating the per-file fanout the
rest of the applier was built around (#2503, BR-3j.c).

This commit performs the source migration:

- `files: Mutex<HashMap<...>>` -> `files: DashMap<FileNdx, Arc<Mutex<FileSlot>>>`
- `register_file` uses `Entry::Vacant`/`Entry::Occupied` and pre-builds
  the slot Arc outside the shard guard so the reorder-buffer allocation
  never widens the lock window.
- `slot_for` clones the Arc and drops the shard read guard at the end
  of the expression; callers never see the DashMap guard, so they
  cannot accidentally hold it across the per-file mutex lock or a
  rayon dispatch.
- `finish_file` uses `DashMap::remove` which returns the owned `(K, V)`
  and drops the shard guard before `Arc::try_unwrap`.
- `Debug` reads `self.files.len()` directly.

The inner `Mutex<FileSlot>` is preserved: it remains the sole gate for
per-file writes so submission order is still enforced through the
`ReorderBuffer`. Public API of `ParallelDeltaApplier` is unchanged.

Adds a concurrency stress test
(`crates/engine/tests/parallel_apply_concurrent.rs`, BR-3j.e #2507)
that spawns N rayon workers each picking a random FileNdx from a pool
of 1000 files and verifies bytes_written matches expected. A second
test races registration and dispatch on overlapping files and asserts
the applier surfaces only typed errors (never panics or corrupts).
On the dev box the stress test reports ~2.17M ops/sec (8 workers,
1000 files, 10000 ops).

No unsafe code added. No clippy waivers. `cargo build -p engine
--no-default-features` still compiles. Targeted nextest runs for
`concurrent_delta` and `parallel_apply` binaries all pass (340 tests
including the 2 new stress tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant