Repository navigation
Description
Group D of the serve-path hot-path audit (siblings: #1788, #1789, #1790). The steady-state per-chunk loop is already lock-free (one relaxed fetch_add for egress); its costs are frame count and copies. Two of the three items touch the wire — CLAUDE.md's pre-launch rule ("wire-breaking changes are fine") applies now and stops applying at the first public deployment, which is what makes this group time-sensitive.
1. Raise the ChunkData frame size from 1 KiB
ADR 005 fixes ChunkData at 1,024-byte chunks, so each served MiB costs 1,024 iterations of (frame validate + copy + postcard encode + QUIC write) at delivery.rs:257-277 / serve_leg.rs:178-206. The 1 MiB payment quantum (CHUNK_BYTES) and bao verification are independent of frame size — ADR 038 states wire framing boundaries are independent of chunk-group boundaries and the codec is the sole verifier — so aligning frames to the 16 KiB bao chunk group (or larger) changes no payment or verification semantics.
Fix: in-place wire change to 16 KiB+ frames, updating both sides in the same PR per pre-launch policy; update ADR 005's chunk-size text.
Improves: ≥16× fewer per-frame costs — validation, copies, allocations, QUIC write submissions — per byte served; directly raises per-core egress and lowers inter-chunk latency jitter.
Leaving as-is limits: per-node throughput ceiling is set by per-frame CPU overhead, not by NIC or disk, and the cost is permanent: after the first deployment this becomes a Tier-3 ALPN bump (cdn/client/v2) with a coordinated migration, so every serving node pays 16× frame overhead for the lifetime of v1.
2. Two full memcpys plus one heap allocation per frame
delivery.rs:265 / serve_leg.rs:186 (chunk.to_vec() out of the Bytes), then wire.rs:185 → crates/protocol/src/framing.rs:57 (postcard::to_allocvec copies the payload again into a fresh allocation), with a third touch in the ChunkFramer coalescer (delivery.rs:88-112).
Fix: encode the frame header/discriminant into a small stack/reused buffer and pass the payload Bytes through with a vectored write; restructure ChunkFramer to slice Bytes instead of copying.
Improves: near-zero-copy payload path — bytes are touched once between the store and the QUIC stream.
Leaving as-is limits: 2–3 memory touches per byte plus one allocation per frame make egress memory-bandwidth- and allocator-bound; the waste scales with concurrent streams and compounds item 1 (at 1 KiB frames it is 2,048+ copies and 1,024 allocations per MiB).
3. Batch/vector QUIC write submissions
Even with larger frames, one write_message await per frame round-trips the QUIC send machinery.
Fix: buffer several encoded frames per write, or use vectored submission. Measure after items 1–2 — they may make this moot.
Improves: fewer send-path syscalls/wakeups per byte.
Leaving as-is limits: residual per-write overhead on the highest-frequency loop in the daemon; low risk of mattering after items 1–2, which is why it ranks last.
Activity
alpergundogdu commentedon Aug 24, 2026
Item 1 is superseded by #1796: instead of picking a coarser fixed frame size,
ChunkDatabecomes variable-size at the sender's choice — non-empty at the protocol level, bounded above only by the 16 MiBMAX_MESSAGE_SIZEframing cap, with practical sizes governed by the credit window / 1 MiB payment cadence. That also delivers most of item 2 (theChunkFramerre-chop buffer disappears; the remaining copy is theto_vec+ postcard encode, still tracked here). The coarser-progress-signal trade-off this creates for stall detection is tracked in #1797. Item 3 (batched/vectored QUIC writes) stays here, to be measured after #1796 lands.Generated by Claude Code
feat(protocol,node)!: sender-chosen ChunkData frames and the Tier-1 e…
perf(node,protocol): zero-copy ChunkData framing via vectored QUIC wr…
perf(node,protocol): zero-copy ChunkData framing via vectored QUIC wr…
perf(node,protocol): zero-copy ChunkData framing via vectored QUIC wr…
fix(node,protocol): close the #1828 review findings on the zero-copy …
perf(node,protocol): zero-copy ChunkData framing via vectored QUIC wr…