Repository navigation
feat: bundle ssh socketpair wire and opt-in SEND_ZC - #8183
Merged
Merged
Conversation
oferchen
force-pushed
the
feat/ssh-zero-copy-bundle
branch
from
October 13, 2026 23:48
b3f84ed to
0d225be
Compare
The remote-shell child's stdin and stdout are now two AF_UNIX SOCK_STREAM socketpairs, one per direction, as upstream pipe.c:57 piped_child() creates them through util1.c:84 fd_pair(). The child's stdout is left non-blocking unless --blocking-io (or rsh/remsh), as in pipe.c:80-82. If either socketpair cannot be created the spawn falls back to anonymous pipes. The choice and any fallback reason are traced at --debug=connect and exposed as SshConnection::wire_primitive(). Windows keeps pipes. On Linux the split halves drive the socket ends through the fast_io io_uring RECV/SEND paths under --io-uring/--no-io-uring, falling back to read/write. With --zero-copy the writer probes the socket once at setup with a zero-length IORING_OP_SEND_ZC; AF_UNIX refuses it with EOPNOTSUPP and the writer settles on plain SEND, traced at --debug=iouring. Wiring the io_uring writer to a stream socket exposed two fast_io defects, fixed here: - submit_send_batch kept several SENDs in flight on one stream socket. A short completion followed by a later chunk reordered the stream (a 2 MiB AF_UNIX write corrupted at offset 262144). Sends are now serial, one SQE in flight, like a write(2) loop. - the socket reader and SEND_ZC drain treated an interrupted io_uring_enter as fatal or as a missing CQE; they now resume the wait instead of resubmitting. The two socketpair audits are marked superseded.
The embedded (russh) transport moved every inbound SSH data chunk through `data.to_vec()` and every outbound write through `buf.to_vec()`, one fresh allocation and copy per chunk in each direction. - Inbound chunks now cross the bridge queue as the `bytes::Bytes` russh decoded, so the only copy left is the one into the caller's buffer. - Outbound writes are copied once into a buffer from a bounded `ChunkPool`. The chunk handed to russh owns that buffer and returns it to the pool when russh drops it, so steady-state writes reuse a few allocations. The pool keeps at most one idle buffer per queue slot and frees anything above 64 KiB. Applied to the production bridge in `connect.rs` (`ChannelReader` / `ChannelWriter`, used by `connect_and_exec`) and to the exported `sync_bridge` halves. Queue bounds, blocking backpressure, the goodbye timeout, EOF and `BrokenPipe` behaviour are unchanged.
SEND_ZC default-on measured +44% wall time on a 2 GiB daemon pull, so the default policy no longer dispatches it. send_zc_policy_permits(Auto) is now false on every build; only an explicit --zero-copy (Enabled) reaches the io_uring writer. The iouring-send-zc feature stays in the default set so --zero-copy works without a rebuild. The default-path tests now assert the SEND_ZC counters stay untouched, and new explicit --zero-copy tests assert SEND_ZC sends are counted where the kernel can run them, with the existing environment classification elsewhere.
io_uring RECV/SEND on the AF_UNIX remote-shell wire measured no gain over read/write, so the wire now engages io_uring only under an explicit --io-uring (IoUringPolicy::Enabled). Auto, SqpollOff and Disabled keep plain syscalls; --io-uring on a host without io_uring, including one with OC_RSYNC_DISABLE_IOURING set, still fails loudly.
Zero-copy is a local decision: a client's --zero-copy / --no-zero-copy covers only its own I/O and is never forwarded, so no argv token or -e capability letter changes and an upstream peer never sees it. Servers opt in on their own: - oc-rsync --daemon --zero-copy / --no-zero-copy sets the daemon-wide policy, stamped onto every module and re-applied on SIGHUP reload. - an SSH server takes --zero-copy via --rsync-path='oc-rsync --zero-copy'. - OC_RSYNC_ZERO_COPY=on|off|auto is read by the daemon at startup and by --server. An explicit flag beats the variable, which beats the default (off). The daemon no longer honours a client-supplied --zero-copy in the session argv; like any unknown long option it is ignored.
oferchen
force-pushed
the
feat/ssh-zero-copy-bundle
branch
from
October 13, 2026 23:53
0d225be to
b729aeb
Compare
The pull whine test drove its cut through `dd bs=1`, which cannot retry EAGAIN. Over the socketpair wire the client leaves the remote shell's stdout non-blocking unless --blocking-io (upstream pipe.c:80-82), so a slow reader made dd die after a few hundred bytes. Both cut tests now pass --blocking-io, as a remote shell that cannot handle a non-blocking stdout needs with upstream too. The blocking-mode test read the shell's fdinfo from `grep ... >&2`. dash applies a command's redirections in the shell before forking, so it measured stderr instead of the socket. The flags are now captured first and printed afterwards.
mevanlc
pushed a commit
to mevanlc/rsync-rs
that referenced
this pull request
Oct 14, 2026
14 of 16 tasks
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.
Bundles three changes to the ssh and socket write paths.
ssh wire over socketpairs
The spawned ssh child's stdin and stdout are now two
AF_UNIXSOCK_STREAMsocketpairs, one per direction, as upstream creates them (pipe.c:57piped_child(), util1.c:84fd_pair()). If the kernel refuses a socketpair, the spawn falls back to anonymous pipes and traces the fallback at--debug=connect. Windows uses pipes. By default the wire uses plain read/write, because io_uring showed no gain there.Embedded ssh bridge
Removes the per-chunk
Veccopies in the embedded ssh bridge.Zero-copy is a local, per-node opt-in
Zero-copy (io_uring
SEND_ZC) is off by default. It applies only on the node where it is requested and is never forwarded to the peer.--zero-copy/--no-zero-copyaffect only its own sockets. They never appear in the remote argv or the-estring.oc-rsync --daemon --zero-copyOC_RSYNC_ZERO_COPY=on|off|auto, read by the daemon and by--server--rsync-path='oc-rsync --zero-copy'--zero-copysent to an oc daemon is now ignored rather than applied.Tests
--zero-copyraises thesend_zccounters; one started without it leaves them unchanged. This was measured on Linux 7.2, whereSEND_ZCreally runs.Not covered here
--serverstdio path and client daemon push have noSEND_ZCwriter.SEND_ZCalso cannot run on the pipe orAF_UNIXstdout that sshd provides.crates/transfer/src/lib.rs:895scans the whole compact flag string, including the-epayload, forz. This is a latent bug and is tracked separately.