Repository navigation
fix(fast_io): let the auto zero-copy policy reach SEND_ZC - #7593
Merged
Merged
Conversation
`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
force-pushed
the
fix/send-zc-auto-policy-gate
branch
from
September 1, 2026 09:26
194985a to
46cccfb
Compare
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.
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.
Problem
IORING_OP_SEND_ZCnever 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:
Autowas a silent synonym forDisabled.IoUringConfig::allow_send_zc,socket_writer_from_fd_zero_copy, and the daemon-sender'sdaemon_socket_writereach matched only onZeroCopyPolicy::Enabled.Enabledis unreachable from an oc client.--zero-copyis an oc-invented local knob, andbuild_full_daemon_argsdeliberately never forwards it to a peer argv (an upstream--serveraborts on an unknown option;oc_flag_forwarding_testspins this). The daemon consequently always seesAuto.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 bycommandop_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).--features iouring-send-zcThe middle row is the point: this change is inert on a stock build. It does not switch anything on by itself.
At the
fast_ioboundary, on a build without the feature,Enabledalready producedIoUring(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 theZeroCopySenderwrapper (which no production call site uses).Fix
Autonow 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 existingis_splice_enabled. The kernel half stays in the cachedsend_zc::is_supportedprobe.Autopermits SEND_ZC only in builds carrying theiouring-send-zccargo feature, which is the IUS-4 release gate that raises the io_uring socket-send kernel floor from 5.6 to 6.0.Disabledstays a hard off on every build;Enabledstays 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
# ErrorsclaimedEnabledpropagates a ring-construction failure; every failure path degrades to the plain writer.--zero-copyhelp text (static help and clap builder) claimed the cargo feature gates SEND_ZC outright; without it an explicitEnabledstill dispatched.Cargo.tomlfeature comments described the feature as gating the dispatch rather than theAutopolicy 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_sendandszcc_send_zc_100k_iopsabort in theirsend_plainbaseline group withWriteZero: "short SEND on loopback"— a shortIORING_OP_SENDon 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 itssend_zcgroup.The two criteria in the tree also disagree:
crates/fast_io/Cargo.tomlsays ">= 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:
Naming the population: this bounds loopback TCP on one 4-core host at 200 MB single-file, and it compares "plain
TcpStreamwrite" 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 thattry_send_zcblocks 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.