Skip to content

docs(transport): investigate splice/vmsplice for SSH stdio - #3428

Merged
oferchen merged 2 commits into
masterfrom
docs/splice-ssh-stdio-audit
Apr 29, 2026
Merged

oferchen merged 2 commits into
masterfrom
docs/splice-ssh-stdio-audit

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Investigation for oc-rsync task #1860. Adds a written audit and a criterion bench skeleton so a follow-up implementer can land the real driver against a measured baseline.

  • Confirms upstream rsync 3.4.1 does NOT use splice (a recursive search of target/interop/upstream-src/rsync-3.4.1/ for splice, vmsplice, tee(, and SPLICE returns one match: an unrelated checktee() shell helper in testsuite/rsync.fns). This is a pure oc-rsync optimisation, no wire-protocol change.
  • Identifies the only realistic targets for zero-copy on the SSH stdio path: file -> ChildStdin pipe (sender) and ChildStdout pipe -> destination file (receiver). The parent does not own the SSH child's TCP socket, so we cannot splice past the SSH child.
  • Documents the multiplex envelope constraint: a 4-byte header (HEADER_LEN, MPLEX_BASE + MessageCode::Data, 24-bit payload length) sits in front of every chunk. Phase 1 keeps the header on a write_all and splices only the payload; phase 3 moves the header onto a vmsplice(SPLICE_F_GIFT) ring.

Phased plan

  • Phase 1 - file -> ChildStdin payload-only splice on the sender path, gated behind a runtime kernel-version check with a fallback to the existing read + write_all loop. Acceptance: bench delta vs the baseline reported in crates/fast_io/benches/splice_pipe.rs.
  • Phase 2 - mirror driver on the receiver: ChildStdout -> destination file. Skip when delta-token paths are in flight (those bytes are not raw file content).
  • Phase 3 - vmsplice(SPLICE_F_GIFT) for the multiplex header. Requires a header-page ring with explicit lifetime tracking against the SSH child's drain.

Out of scope: socket-to-pipe (handled by the SSH child), checksum/delta-token paths, compression paths.

Risks

vmsplice page lifetime, SPLICE_F_NONBLOCK semantics, short splice returns, EPIPE on closed peer, default 64 KiB pipe capacity (F_SETPIPE_SZ lift), interaction with --bwlimit user-space pacing. Each is enumerated with a mitigation in the audit doc.

Files

  • docs/audits/splice-ssh-stdio.md - full audit with ASCII flow diagram, phased plan, risks, and follow-up task list.
  • docs/perf-roadmap.md - new index file linking to this audit.
  • crates/fast_io/benches/splice_pipe.rs - criterion bench skeleton with a real read_write_baseline (Linux) and a splice_baseline placeholder slot. Non-Linux targets compile to a no-op group.
  • crates/fast_io/Cargo.toml - register the new bench.

Test plan

  • CI fmt + clippy on Linux, macOS, Windows.
  • CI nextest passes (no test changes; bench compiles as a separate target).
  • Manual: cargo bench -p fast_io --bench splice_pipe succeeds on Linux and prints the placeholder notice on the splice slot.
  • Manual: cargo build --benches -p fast_io succeeds on macOS / Windows.

Tracking: oc-rsync #1860. Follow-ups: #1861 (driver), #1862 (sender wiring), #1863 (receiver mirror), #1864 (vmsplice header ring), #1865 (Linux bench suite), #1866 (io_uring chooser), #1867 (interop byte-identity).

Audit confirms upstream rsync 3.4.1 does not use splice. Identifies the
file-to-pipe (sender) and pipe-to-file (receiver) edges as the only
realistic targets for zero-copy on the SSH stdio path, since the parent
does not own the SSH child's TCP socket. Documents the multiplex envelope
constraint (4-byte header + 24-bit payload) and proposes a three-phase
plan: payload splice on the sender, payload splice on the receiver, and
vmsplice for the header ring. Risks cover vmsplice page lifetime,
SPLICE_F_NONBLOCK semantics, EPIPE on closed peers, and interaction with
--bwlimit. Adds docs/perf-roadmap.md as the index.
Provides the criterion baseline for the SSH-stdio splice investigation.
The Linux body runs a real read+write_all loop from a temp file through a
drained pipe at three sizes (64 KiB, 1 MiB, 16 MiB), establishing the
comparison point for the future splice driver. The splice_baseline slot
is a placeholder that records a constant for now; follow-up #1861 wires
the real fast_io::splice_pipe driver into that slot. Non-Linux targets
compile to a no-op group so cargo bench succeeds on macOS and Windows.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Apr 29, 2026
@oferchen
oferchen merged commit 7d348ae into master Apr 29, 2026
48 of 49 checks passed
@oferchen
oferchen deleted the docs/splice-ssh-stdio-audit branch April 29, 2026 10:21
oferchen added a commit that referenced this pull request May 1, 2026
* docs(transport): investigate splice()/vmsplice() for SSH stdio (#1860)

Audit confirms upstream rsync 3.4.1 does not use splice. Identifies the
file-to-pipe (sender) and pipe-to-file (receiver) edges as the only
realistic targets for zero-copy on the SSH stdio path, since the parent
does not own the SSH child's TCP socket. Documents the multiplex envelope
constraint (4-byte header + 24-bit payload) and proposes a three-phase
plan: payload splice on the sender, payload splice on the receiver, and
vmsplice for the header ring. Risks cover vmsplice page lifetime,
SPLICE_F_NONBLOCK semantics, EPIPE on closed peers, and interaction with
--bwlimit. Adds docs/perf-roadmap.md as the index.

* bench(fast_io): add splice_pipe benchmark skeleton (#1860)

Provides the criterion baseline for the SSH-stdio splice investigation.
The Linux body runs a real read+write_all loop from a temp file through a
drained pipe at three sizes (64 KiB, 1 MiB, 16 MiB), establishing the
comparison point for the future splice driver. The splice_baseline slot
is a placeholder that records a constant for now; follow-up #1861 wires
the real fast_io::splice_pipe driver into that slot. Non-Linux targets
compile to a no-op group so cargo bench succeeds on macOS and Windows.
oferchen added a commit that referenced this pull request May 5, 2026
* docs(transport): investigate splice()/vmsplice() for SSH stdio (#1860)

Audit confirms upstream rsync 3.4.1 does not use splice. Identifies the
file-to-pipe (sender) and pipe-to-file (receiver) edges as the only
realistic targets for zero-copy on the SSH stdio path, since the parent
does not own the SSH child's TCP socket. Documents the multiplex envelope
constraint (4-byte header + 24-bit payload) and proposes a three-phase
plan: payload splice on the sender, payload splice on the receiver, and
vmsplice for the header ring. Risks cover vmsplice page lifetime,
SPLICE_F_NONBLOCK semantics, EPIPE on closed peers, and interaction with
--bwlimit. Adds docs/perf-roadmap.md as the index.

* bench(fast_io): add splice_pipe benchmark skeleton (#1860)

Provides the criterion baseline for the SSH-stdio splice investigation.
The Linux body runs a real read+write_all loop from a temp file through a
drained pipe at three sizes (64 KiB, 1 MiB, 16 MiB), establishing the
comparison point for the future splice driver. The splice_baseline slot
is a placeholder that records a constant for now; follow-up #1861 wires
the real fast_io::splice_pipe driver into that slot. Non-Linux targets
compile to a no-op group so cargo bench succeeds on macOS and Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant