Repository navigation
fix(node,protocol): close the #1828 review findings on the zero-copy frame path - #1835
Merged
Merged
Conversation
…-copy frame path The mid-export-fault test's doc block sat above the zero-target test inserted in front of it, so the fault test read as undocumented and the zero-target test opened with a summary about a fault it does not exercise. Re-attach it. `frame_target` does not floor at one bao chunk group — only its room term does, and `payment.frame_target_bytes` may be as low as 1. State what actually makes a zero target unreachable: `frame_target` never returns zero. Name the queue where a comment still named the removed `buf`, cut the two changelog-voice phrasings, drop the claim that the delivery loop calls `encode_chunk_frame`, and say what the returned byte count is on both framers. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Every accounting refusal on the serve path was correct and silent. The delivery aborts without `StreamEnd`, the client neither receives a mislabelled frame nor pays the closing voucher — and the only trace is a `debug!` in the dispatch sink, below the default `RUST_LOG=info`. To an operator that reads as a client that hung up. Give the four framing refusals a `tracing::error!` with the hash, give `CoherentFrameProducer` the `hash` field its cache-hit twin already carries so its encode fault logs the same way, and carry the cause as `FrameAccountingFault` so both serve loops can meter `decdn_serve_frame_accounting_fault_total` without misfiling a store fault or a peer disconnect as a node bug. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ilent Each of these is unreachable today. Each also degrades the wrong way if that ever stops being true, and the failures they guard are the ones nobody would find. `write_varint_u32` dropped its length prefix to zero bytes and returned `Ok`, after which `write_frame` wrote the payload anyway — a frame with no prefix, desyncing the peer's stream and the cumulative wire-byte count vouchers are paid against, silently on both sides. `encode_varint_u32` now stops rather than counting a byte it did not write, and the prefix write refuses a short buffer. `pump` dropped the encode future on both success and fault, so the terminal state was enforced only by its caller remembering to set `faulted`; it poisons itself now. A closed channel under a live encoder is a contradiction, not end-of-range. Both `Ok(None)` doors — the one that tells the serve loop the blob is complete — now rest on the queue, not only on its counter, and `drain_frame` uses `checked_sub` so a desync cannot clamp that counter to zero. Also: `ChunkTooLarge`'s field is `frame_len`, since it is always larger than the `payload_len` the caller passed and reading it as one is what confused review; and `write_chunk_bufs` takes its buffers by value, since `write_all_chunks` empties them and nothing has a use for what is left. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…, and the encode ceiling Nothing asserted the property the whole change exists for. Every framer test routed through the coalescing test shims, and the `drain_frame` test compared `total` against a sum of the same lengths `total` was built from — a tautology. A `drain_frame` rewritten to concatenate passed the entire suite. Assert the chunk counts instead, at both framers and at `drain_frame`, and cover the boundary cases the shape can break on: a frame ending exactly on an item boundary, a target past everything queued, and an under-counting `queued` that must not be clamped to zero. Verified by falsification — a coalescing `drain_frame` now fails five of them. Also bring the cache-hit fault test up to its coherent twin, which already asserted the refusal is the poison guard's and that the queue was cleared; pin `encode_chunk_frame`'s ADR 013 ceiling, which is the door an out-of-tree caller reaches; and give the miss leg's only large blob a position-varying fill, since a constant one compares equal under a within-frame permutation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Coverage reportTotal: 82.00% (was 82.01%, ▼ 0.02%) — 68305/83299 lines
History
|
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.
Continues #1828 (merged as
9595aee5), which moved thecdn/client/v1serve hot path from "encode aChunkDataframe into one contiguous buffer" to "encode a ≤9-byte header on the stack + vectored QUIC write of reference-countedBytes".A multi-agent review of that PR after merge found no correctness bug — byte accounting, the credit-window bound,
faultedterminality, the metering split, and cancel-safety all hold, and the perf claim is real end to end (quinn_proto::SendBuffer::writemoves eachBytesintounacked_segmentswithout copying). What it did find was docs that no longer describe the code, refusals nobody can observe, and the absence of any test for the property the change exists for. No wire change; no behaviour change on any reachable path.docs— correct stale and misattributed docs (ba2a2626)a_mid_export_fault_propagates's doc block and itsfn, so the fault test read as undocumented and the zero-target test opened with a summary about a fault it does not exercise. Re-attached.frame_target"floors at one bao chunk group". It does not — only itsroomterm does, andpayment.frame_target_bytesmay be as low as1, which yieldsframe_target == 1. They now state what actually makes a zero target unreachable: it never returns zero.buffield; two docstrings carried changelog voice ("no longer"); one test justified itself by a caller (encode_chunk_framefrom the delivery loop) that no longer exists; "coalesces" survived in the protocol crate after being fixed in the node crate.usizeis — it is simultaneously what the header declares to the client and what the serve loop bills for — andCoherentFrameProducer::next_frame_chunksgains the# Errorssection its cache-hit twin already had.fix— surface serve-path framing faults to operators (888759d5)Every accounting refusal on this path was correct and silent: the delivery aborts without
StreamEnd, so the client neither receives a mislabelled frame nor pays the closing voucher, and the only trace was adebug!in the dispatch sink — below the project's defaultRUST_LOG=info. To an operator that reads as a client that hung up.tracing::error!with the hash at each framing refusal.CoherentFrameProducergains thehashfield its cache-hit twin already carried, so its encode fault logs the same way. Previously the miss leg's fault was strictly less observable than the hit leg's.FrameAccountingFaultmarker carries the cause, so both serve loops meterdecdn_serve_frame_accounting_fault_totalwithout misfiling a store fault or a peer disconnect as a node bug. Documented inadr/appendix-observability.mdas a latent-bug report — alert on> 0.fix— make impossible framing states loud rather than silent (28259046)Each is unreachable today; each degrades the wrong way if that stops being true.
write_varint_u32dropped its length prefix to zero bytes and returnedOk, after whichwrite_framewrote the payload anyway — a frame with no prefix, desyncing the peer's stream and the cumulative wire-byte count vouchers are paid against, silently on both sides. Of the threeencode_varint_u32callers it was the only one that degraded instead of erroring.encode_varint_u32no longer counts a byte it did not write.pump()dropped the encode future on both success and fault, so the terminal state was enforced only by its caller remembering to setfaulted. It poisons itself now. A closed channel under a live encoder is a contradiction, not end-of-range.Ok(None)doors — the ones that tell the serve loops the blob is complete — now rest on the queue rather than only on its counter, anddrain_frameuseschecked_subso a desync cannot clamp that counter to zero.ChunkTooLarge's field is nowframe_len: it is always larger than thepayload_lenthe caller passed, and reading it as one is exactly what confused review on perf(node,protocol): zero-copy ChunkData framing via vectored QUIC writes (#1791) #1828.write_chunk_bufstakes its buffers by value, sincewrite_all_chunksempties them.test— pin the zero-copy shape (f068d2c8)Nothing asserted the property the whole change exists for. Every framer test routed through the coalescing test shims, and the
drain_frametest comparedtotalagainst a sum of the same lengthstotalwas built from — a tautology. Adrain_framerewritten to concatenate passed the entire suite.Now the chunk counts are asserted at both framers and at
drain_frame, plus the boundary cases the shape can break on: a frame ending exactly on an item boundary, a target past everything queued, and an under-countingqueued. Verified by falsification — a coalescingdrain_framefails five of them.Also: the cache-hit fault test now matches its coherent twin (refusal by name, queue cleared);
encode_chunk_frame's ADR 013 ceiling is pinned, since that is the door an out-of-tree caller reaches; and the miss leg's only large blob gets a position-varying fill, because a constant one compares equal under a within-frame permutation.Verification
cargo clippy --workspace --all-targets -- -D warningscleancargo nextest run --workspace— 3046 passed, 0 failedcargo test -p decdn-node --test client_loopback110 pass;--test node_to_node_pull_through4 passcargo fmt -- --check,cargo doc --no-deps --workspace,markdownlintcleanlen→frame_lenrename, nothing elseOut of scope
Two issues filed rather than bundled here:
align_range,read_at, the dispatch log sink)FrameQueue/FrameChunks. Deferred deliberately: it would delete the very guards this PR adds, so doing both at once would be incoherent. Harden first, refactor second.🤖 Generated with Claude Code