Skip to content

fix(fast_io): let the auto zero-copy policy reach SEND_ZC - #7593

Merged
oferchen merged 1 commit into
masterfrom
fix/send-zc-auto-policy-gate
Sep 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/send-zc-auto-policy-gate

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Problem

IORING_OP_SEND_ZC never flew on any oc-to-oc transfer, on any kernel, in any build.

Three things had to line up and one of them could not:

  1. Auto was a silent synonym for Disabled. IoUringConfig::allow_send_zc, socket_writer_from_fd_zero_copy, and the daemon-sender's daemon_socket_writer each matched only on ZeroCopyPolicy::Enabled.
  2. Enabled is unreachable from an oc client. --zero-copy is an oc-invented local knob, and build_full_daemon_args deliberately never forwards it to a peer argv (an upstream --server aborts on an unknown option; oc_flag_forwarding_tests pins this). The daemon consequently always sees Auto.
  3. The runtime kernel-opcode probe was correct and is unchanged.

So the whole SEND_ZC transport was dead code in practice.

Measurement

Linux 7.0.0 (advertises IORING_OP_SEND_ZC), 4 cores. Instrument: tracepoint:io_uring:io_uring_submit_req, counting by comm and op_str; a 200 MB daemon pull over loopback with the stock client (daemon log confirms the argv is --server --sender -e.LsfxCIvu . m/big.bin, i.e. no --zero-copy).

build io_uring rings created by the sender SEND_ZC SQEs
master, default features 0 0
this branch, default features 0 0
this branch, --features iouring-send-zc 3 6400

The middle row is the point: this change is inert on a stock build. It does not switch anything on by itself.

At the fast_io boundary, on a build without the feature, Enabled already produced IoUring(send_zc_active=true) and one real SEND_ZC SQE — so the feature was never the gate the docs claimed it was, only a threshold change (16 KiB -> 4 KiB) plus the ZeroCopySender wrapper (which no production call site uses).

Fix

Auto now means what its name says: dispatch when the build permits it and the kernel advertises the opcode, else fall back. The permission half is one predicate, fast_io::send_zc_policy_permits, shared by the config, the factory, and the daemon writer — the same shape as the existing is_splice_enabled. The kernel half stays in the cached send_zc::is_supported probe.

Auto permits SEND_ZC only in builds carrying the iouring-send-zc cargo feature, which is the IUS-4 release gate that raises the io_uring socket-send kernel floor from 5.6 to 6.0. Disabled stays a hard off on every build; Enabled stays force-on and keeps degrading gracefully rather than erroring, which is what it has always done.

This PR does not promote the feature to any default set. That is a separate release-policy decision with a measurement precondition, and the numbers below argue against it.

Doc drift corrected in the same commit

  • The factory's # Errors claimed Enabled propagates a ring-construction failure; every failure path degrades to the plain writer.
  • The --zero-copy help text (static help and clap builder) claimed the cargo feature gates SEND_ZC outright; without it an explicit Enabled still dispatched.
  • Both Cargo.toml feature comments described the feature as gating the dispatch rather than the Auto policy arm.

What this does not fix

The IUS-3 promotion criteria remain unmeasurable with the instruments in the tree. Both ius_3_send_zc_vs_send and szcc_send_zc_100k_iops abort in their send_plain baseline group with WriteZero: "short SEND on loopback" — a short IORING_OP_SEND on a full loopback buffer that the harness treats as fatal instead of looping. Reproduced on unpatched master, so it is pre-existing and independent of this change. Neither bench ever reaches its send_zc group.

The two criteria in the tree also disagree: crates/fast_io/Cargo.toml says ">= 10% throughput on >= 2 of 4 workloads, no workload regressing by > 2%", while the bench's own module doc cites ">= 1.1 ratio on 3 of 4 workloads and >= 10% CPU reduction on 2 of 4" — and states that the CPU half is not measured by the harness at all.

An end-to-end stand-in A/B (11 alternating reps, 200 MB daemon pull, source page-cached, destination on tmpfs, only the cargo feature differing) measured a large regression, not a win:

cell median wall time throughput
plain socket writer 0.128 s ~1.56 GB/s
SEND_ZC 0.519 s ~385 MB/s

Naming the population: this bounds loopback TCP on one 4-core host at 200 MB single-file, and it compares "plain TcpStream write" against "io_uring SEND_ZC writer" — the two variables the default flip would change together. It says nothing about a real NIC, which is where SEND_ZC's copy avoidance is supposed to pay. The likely mechanism is that try_send_zc blocks on both the transfer and notification CQEs per submission, serialising every send behind a page-release round trip that buys nothing on loopback.

Recommendation: keep the feature opt-in. On the evidence available, the "no workload regressing by > 2%" criterion fails badly, and the criterion that would establish a win cannot currently be run.

`ZeroCopyPolicy::Auto` is the default every transfer carries, and it was a
silent synonym for `Disabled` on the socket-send path: both
`IoUringConfig::allow_send_zc` and `socket_writer_from_fd_zero_copy` matched
only on `Enabled`, and the daemon-sender's writer factory short-circuited
the same way. `Enabled` is the only arm that ever dispatched, and it is
unreachable in practice - `--zero-copy` is an oc-invented local knob that
`build_full_daemon_args` deliberately never forwards to a peer argv, because
an upstream `--server` aborts on an unknown option. The daemon therefore
always saw `Auto`, so `IORING_OP_SEND_ZC` never flew on any oc-to-oc
transfer regardless of kernel or build flags. Measured on Linux 7.0.0, which
advertises the opcode: a daemon pull of a 200 MB file submits 0 SEND_ZC SQEs
and creates no io_uring ring at all on the sender socket.

Give `Auto` the meaning its name states: dispatch when the build permits it
and the kernel advertises the opcode, else fall back. The permission half is
now one predicate, `send_zc_policy_permits`, shared by the config, the
factory, and the daemon writer, mirroring `is_splice_enabled`; the kernel
half stays where it was, in the cached `send_zc::is_supported` probe.

`Auto` permits SEND_ZC only in builds carrying the `iouring-send-zc` cargo
feature. That feature is the IUS-4 release gate, which raises the io_uring
socket-send kernel floor from 5.6 to 6.0, so a stock build keeps the plain
socket writer and is unchanged - re-measured with the same tracepoint
instrument: 0 SEND_ZC SQEs before and after this commit on a default build,
6400 with `--features iouring-send-zc`. This commit does not promote the
feature to the default set; that decision still needs its numbers.

Correct three doc-drift sites in the same change. The factory's `# Errors`
claimed `Enabled` propagates a ring-construction failure when every failure
path degrades to the plain writer; the `--zero-copy` help text in both the
static help and the clap builder claimed the feature gates SEND_ZC outright,
when without it an explicit `Enabled` still dispatched at a 16 KiB
threshold; and both Cargo.toml feature comments described the feature as
gating the dispatch rather than the `Auto` policy arm.
@oferchen
oferchen force-pushed the fix/send-zc-auto-policy-gate branch from 194985a to 46cccfb Compare September 1, 2026 09:26
@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026
@oferchen
oferchen merged commit a622325 into master Sep 1, 2026
76 checks passed
@oferchen
oferchen deleted the fix/send-zc-auto-policy-gate branch September 1, 2026 16:28
oferchen added a commit that referenced this pull request Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60
most recently merged pull requests, 44 were absent; of the most recent 45,
43 were absent. Nothing from #7574 onward was recorded at all.

Each entry is derived from what the pull request actually landed - the merge
commit and the body - not from its title. Three cases where those differ:

  * #7616 ships far more than the doc-alias correction its body describes:
    the `upstream_version` pin moves to 3.5.0 and `--version` starts naming
    `quic`, `sd-notify`, `vmsplice` and `send_zc`.
  * #7618 also adds the pull-request rustdoc-link job its body says was
    filed separately, which is what closes the master-only-gate recurrence.
  * #7602's squash carries the closed #7597 as its first commit, so the
    directory-obstacle half is recorded under #7602.

#7587 is deliberately not recorded. Its merge commit is empty: the change
had already landed as #7563, which the section already names.

Entries extend the existing Keep a Changelog groups and the bold
sub-groupings. Clusters that are one story carry one entry with several
references: the FERROR_XFER routing and its two-phase drain (#7576, #7581),
the connection-FSM close edge and the accept loop that outlives a session
error (#7579, #7590), the three detaching daemon suites (#7578, #7588,
#7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation
retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615,
#7620).

Only `## [Unreleased]` is touched; every released section, including the
3.4.4 statements that were correct when written, is byte-identical.
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