Skip to content

feat(ssh): build the socketpair stderr channel by default - #8219

Closed
oferchen wants to merge 2 commits into
masterfrom
feat/ssh-socketpair-stderr-default
Closed

oferchen wants to merge 2 commits into
masterfrom
feat/ssh-socketpair-stderr-default

Conversation

@oferchen

@oferchen oferchen commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Turn on the rsync_io ssh-socketpair-stderr feature by default. Default builds now ship the socketpair stderr primitive and, under async-ssh, the event-driven stderr drain.
  • This changes what is compiled, not how a default binary behaves: the sync SSH spawn path already captures stderr through a socketpair on Unix, and nothing on that path depends on the flag. Measured on a quiet host: syscall counts and wall time match master within the A/A noise floor.
  • Correct the docs that described a pipe as the default stderr transport, and pin the new default with a test.

Details

What the flag gates

Site Gate Effect of the flip on a default binary
ssh::socketpair_stderr (standalone primitive) ssh-socketpair-stderr Compiled in; no production caller
ssh::async_stderr_drain async-ssh + ssh-socketpair-stderr None: async-ssh is not a default feature
AsyncSshTransport stderr channel async-ssh + ssh-socketpair-stderr None, same reason
tracing dependency of rsync_io pulled in by the feature Linked
aux_channel::configure_stderr_channel (sync spawn path) none Unchanged: socketpair on Unix, pipe fallback with a once-per-process warning

core and cli depend on rsync_io with default features, so the default reaches the oc-rsync binary without a workspace forwarding feature. The daemon crate keeps default-features = false. Windows compiles the same way as before, and stderr stays on the anonymous pipe there.

Upstream reference: pipe.c:57 piped_child() creates the remote-shell child's stdin and stdout with util1.c:84 fd_pair(), a socketpair(2) under HAVE_SOCKETPAIR. Upstream leaves the child's stderr inherited, so capturing it through a socketpair is oc-specific and predates this PR.

Docs corrected

docs/ssh-transport.md, docs/oc-rsync.1.md, docs/operator-migration-guide-vNEXT.md and the README said default builds used a pipe for SSH stderr and the feature swapped in a socketpair. The code has used a socketpair on Unix regardless of the feature. The docs now describe what the code does, along with what the feature adds and how to opt out (--no-default-features). The design doc's backwards-compatibility section records the promotion.

Measured: release builds, master 4d50d1b vs this branch, quiet host

These measurements were redone on a quiet host. The first set ran while another job's stress tests held the host's load near 300, so it could not support a gate decision.

Method. The run started only once the 1-minute load was under 2 and no other benchmark was running; that took 42 minutes of waiting. Load was 0.24 at the start and at most 1.22 during the run.

Cases. All four use -e ssh to localhost with --rsync-path set to the binary under test:

  • push of 2,000 files of 2 KiB each;
  • push of one 256 MiB file;
  • pull of the same 2,000 files;
  • -vvv push of the 2,000 files.

Binaries. Three are compared: master, this branch, and a byte-identical copy of master. The copy is an A/A control and sets the noise floor.

Counts. Each case runs 9 interleaved rounds of master / branch / copy. Syscalls are strace -f -c totals for the client plus its ssh child, taken 3 times per binary. The tables show the median, and min-max in brackets.

Gate. A case passes when branch minus master is within max(3%, A/A delta) for wall time and within the A/A delta for syscalls.

Wall time (seconds):

Case Master Branch A/A copy Branch vs master A/A vs master Verdict
push, many files 0.346 (0.324-0.383) 0.368 (0.351-0.387) 0.377 (0.334-0.405) +6.4% +9.0% PASS
push, 256 MiB 0.517 (0.461-0.537) 0.465 (0.459-0.921) 0.492 (0.448-0.885) -10.1% -4.8% PASS
pull, many files 0.319 (0.308-0.337) 0.324 (0.314-0.344) 0.314 (0.304-0.334) +1.6% -1.6% PASS
push -vvv 0.367 (0.352-0.375) 0.359 (0.329-0.369) 0.358 (0.341-0.375) -2.2% -2.5% PASS

The many-file push wall time is +6.4%, but the A/A copy differs from master by +9.0%, so the gap is within noise.

Syscalls (median of 3):

Case Master Branch A/A copy Branch vs master A/A vs master Verdict
push, many files 9,080 9,097 9,109 +17 +29 PASS
push, 256 MiB 53,688 53,691 53,691 +3 +3 PASS
pull, many files 31,054 30,845 30,966 -209 -88 PASS
push -vvv 36,228 35,279 36,109 -949 -119 PASS

Every syscall and wall difference sits inside the A/A noise floor or the 3% band, consistent with an unchanged runtime path.

Test plan

  • CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl.
  • cargo fmt --all -- --check and python3 tools/ci/check_rustfmt_all.py
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings
  • cargo clippy -p rsync_io --all-targets --no-deps -- -D warnings (defaults), with --no-default-features, and -p core with defaults
  • cargo check -p rsync_io -p core --tests --target x86_64-pc-windows-gnu
  • cargo nextest run -p rsync_io --all-features (1518 passed)
  • cargo nextest run -p rsync_io --no-default-features -E 'binary(ssh_stderr_default_path)' (2 passed)
  • cargo nextest run -p rsync_io -E 'binary(ssh_stderr_default_path) | binary(ssh_stderr_socketpair_propagation) | binary(ssh_stderr_child_exit)' (7 passed)
  • cargo nextest run --all-features -E 'binary(ssh_transport) | binary(server_diagnostics_reach_client)' (24 passed)
  • python3 tools/ci/unsafe_owner_deps.py, cargo run -p xtask -- no-placeholders, cargo run -p xtask -- citations
  • New test ssh_socketpair_stderr_is_a_default_feature reads the rsync_io manifest and fails when the feature is removed from default (mutation checked). spawn_path_surfaces_child_stderr now runs with and without the feature instead of only without it.

Coordination

Conventional commit prefix

  • feat: - new user-visible feature

Pre-merge checklist

  • Conventional commit prefix on PR title matches the change category.
  • cargo fmt --all run locally.
  • CHANGELOG.md updated if user-visible.
  • SECURITY.md updated if security-relevant.
  • No references to internal tooling or non-human authoring aids; hyphens, not em-dashes.

The sync SSH spawn path already captures stderr through a socketpair on
Unix, so the flag only adds the socketpair primitive and the async-ssh
stderr drain. Ship them in default builds, pin the default in a test,
and correct the docs that described a pipe as the default.
@github-actions github-actions Bot added the enhancement New feature or request label Oct 20, 2026
@oferchen
oferchen marked this pull request as ready for review October 20, 2026 13:21
@oferchen
oferchen marked this pull request as draft October 20, 2026 14:39
@oferchen

Copy link
Copy Markdown
Owner Author

Superseded by #8224. Analysis showed ssh::socketpair_stderr had no production caller, and upstream rsync never captures the ssh child's stderr (pipe.c piped_child only redirects stdin/stdout via fd_pair). #8224 mirrors upstream: the child inherits stderr, the server sets fd 2 blocking after setup (main.c:1364), and the ssh-socketpair-stderr feature is removed.

@oferchen oferchen closed this Oct 20, 2026
@oferchen
oferchen deleted the feat/ssh-socketpair-stderr-default branch October 20, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant