Repository navigation
perf: reduce syscalls with writev, BufReader, and message coalescing - #2348
Merged
Merged
Conversation
Three optimizations targeting I/O syscall overhead: 1. write_vectored in ReusableBufWriter: combine buffer flush + large chunk into a single writev syscall (was 2 write calls per file) 2. Socket-level BufReader (64KB): batch 4-byte multiplex header reads with payload reads into fewer recvfrom syscalls (-83%, 37K → 6.4K) 3. WholeFile message coalescing: single-chunk files send one channel message instead of Begin+Chunk+Commit (3 sends → 1), reducing futex overhead for small files Daemon benchmark (10K files, 422MB): - Initial copy: 1.63x faster than upstream rsync (555ms vs 903ms) - Incremental: 1.82x faster than upstream rsync (76ms vs 137ms) - Total syscalls: 136K (was 164K, -17%)
oferchen
added a commit
that referenced
this pull request
May 1, 2026
perf: reduce syscalls with writev, BufReader, and message coalescing
oferchen
added a commit
that referenced
this pull request
May 5, 2026
perf: reduce syscalls with writev, BufReader, and message coalescing
2 of 3 tasks
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
#4408) Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
#4408) Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
#4408) Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#4408) Adds `spill_env_e2e_engages_spill_layer` under `crates/engine/tests/spill_env_e2e.rs`. The test seeds 10 MiB of mixed pseudo-random content into a `TempDir`, runs `LocalCopyPlan::execute` with `OC_RSYNC_SPILL_THRESHOLD_BYTES=131072` and `OC_RSYNC_SPILL_DIR` pointed at a scratch tempdir, then asserts at least one `.tmp` file landed in the spill directory. Marked `#[ignore]` until env-var wiring (STN-8 parse, STN-9/STN-10 engine plumbing) lands. The file compiles, the inline `EnvGuard` serialises env mutation via a per-process `Mutex`, and an inline xorshift PRNG keeps the corpus deterministic without adding `rand` as a dev-dependency. Gated on `cfg(unix)` because env-var semantics differ on Windows. Closes #2348.
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
writevsyscall inReusableBufWriter, eliminating double-write per filerecvfromsyscalls (37K → 6.4K, -83%)WholeFilechannel message instead ofBegin+Chunk+Commit(3 sends → 1), reducing futex overheadBenchmark Results (daemon, 10K files, 422MB)
Syscall Comparison (strace -f -c, initial copy)
Test Plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo nextest run --workspace --all-features— 21,725 tests pass