throughput: P+Q fast-path FEC — cheap proactive repair for R≤2 #51
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
femboy/yip!51
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/throughput-pq-fec"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adds a generator scheme to the RS FEC codec so proactive repair for the common low-redundancy cases (R=1, R=2) is cheap: RAID-6 P+Q (P = XOR all-ones, Q = 2^i syndrome, MDS for R≤2) for non-ARQ classes, with the existing Cauchy generator for ARQ classes and R≥3. R=1 repair becomes a pure XOR (no GF multiply). Lever 1 of 3 toward single-core-10-Gbit (cheap FEC → fast AEAD → AF_XDP I/O).
Why
On a 1-core box the throughput ceiling is single-core CPU. Post-4a the per-packet budget for ~10 Gbit is ~1.2 µs; the general Cauchy repair (~1.3 µs) alone busts it, so keeping proactive repair on a lossy link forced throughput down. P+Q makes R≤2 repair sub-µs, so loss protection stays on within budget — cheap-and-on when there's loss, ~free when clean (the
AdaptiveControlleralready picks R). Bandwidth is free on the target servers, so running generous cheap repair costs nothing that matters.This finishes the "XOR fast path" 4a deliberately deferred — deferred because mixing XOR-for-R=1 with Cauchy-for-R≥2 made a repair symbol ambiguous to the decoder. Resolved here by signaling the generator scheme in the reserved
payload_id[3]byte 4a set aside.How
crates/yip-transport/src/rs.rs—Scheme {Cauchy, Pq},repair_row(scheme,k,m), scheme args onencode_repair/decode_source(with the PQm≥2reject), R=1 pure-XOR fast path.gf256untouched (2^i built incrementally).crates/yip-transport/src/fec.rs— scheme selection keyed onparams.arq(see below),payload_id[3]pack/parse, reassembler scheme threading + ingest guard (rejects out-of-range P+Q rows, unknown scheme ids, per-block scheme mismatch).payload_idlayout[codec_tag=0x01][symbol_index:u16 BE][scheme:u8].yip-wire::Frame,wire_glue.rs,Symbolunchanged.Scheme is keyed on the stable
params.arqflag, not per-call R. This is load-bearing: the ARQ retransmit path re-encodes the sameobject_idin a separate call with a different repair count (RETX_EXTRA_REPAIR=4), and all symbols of one object must use the same generator or the reassembler rejects the mismatched batch. ARQ classes always use Cauchy (retransmit-compatible); non-ARQ classes (encoded once, never retransmitted) get the P+Q fast path — exactly where proactive repair is always on. (A review caught this as a Critical bug in the first pass and it was fixed before merge — see the ARQ regression test.)Results
transport_encode_1300.yip-transport69/69, workspace 346/346, clippy clean.Final whole-branch review (opus): READY TO MERGE, no Critical/Important — single-scheme-per-object invariant verified airtight against the
dataplane.rsARQ caller.Wire compatibility
The scheme byte makes the RS-v1 wire self-describing; a 4a peer (
payload_id[3]=0) reads as Cauchy. A P+Q sender's R≤2 repair needs a P+Q-aware receiver. Fine under the pre-release "peers rebuild together" posture.Deferred follow-ups (non-blocking)
rs::repair_rowreturns an all-zero row for an invalidSCHEME_PQm≥2(currently guarded by both callers; adebug_assert!/Optionwould harden it).RESULTS.md; the R=1 win is the measured, targeted one).Design docs
docs/superpowers/specs/2026-07-11-throughput-pq-fec-design.mddocs/superpowers/plans/2026-07-11-throughput-pq-fec.md🤖 Generated with Claude Code
https://claude.ai/code/session_01RVP6NnbDMAg1iTsMMTfL86