FEC object batching: amortize the ~24µs RaptorQ per-object setup across N packets #27

Closed
opened 2026-07-03 19:11:09 +00:00 by vxfemboy · 1 comment
vxfemboy commented 2026-07-03 19:11:09 +00:00 (Migrated from github.com)

Design: docs/superpowers/specs/2026-07-03-fec-object-batching-design.md.

RaptorQ Encoder::new pays its full intermediate-symbol solve (~24 µs/packet, ~80% of egress CPU) whenever repair > 0, because yip makes one object per packet. Batching N sealed packets into one object amortizes it to ~24 µs / N.

Key design points (see spec): container = [u16 len][sealed]…; per-packet AEAD counter derived (base+i) so no wire-format change; the accumulator buffers plaintext and seals the batch consecutively at flush so counters stay contiguous (the LossDetector fills counter gaps, so a separate counter space isn't viable); accumulator lives in DataPlane, flushed via a new Dispatch::flush_egress after tick. Bulk-only (Realtime/Default stay batch=1). Defaults N=8, 1 ms flush.

Honest scope: clean links already bypass the encoder (repair == 0), so this helps only the Bulk-under-loss egress path, not clean-link throughput. Gate: arq_recovers_bulk_loss ≥ 98% under batching. Blocked-by review sign-off on the spec's open questions (N, flush deadline, all-or-nothing recovery risk).

**Design:** `docs/superpowers/specs/2026-07-03-fec-object-batching-design.md`. RaptorQ `Encoder::new` pays its full intermediate-symbol solve (~24 µs/packet, ~80% of egress CPU) whenever `repair > 0`, because yip makes **one object per packet**. Batching N sealed packets into one object amortizes it to ~24 µs / N. Key design points (see spec): container = `[u16 len][sealed]…`; per-packet AEAD counter *derived* (`base+i`) so **no wire-format change**; the accumulator buffers **plaintext** and seals the batch consecutively at flush so counters stay contiguous (the `LossDetector` fills counter gaps, so a separate counter space isn't viable); accumulator lives in `DataPlane`, flushed via a new `Dispatch::flush_egress` after `tick`. Bulk-only (Realtime/Default stay batch=1). Defaults **N=8, 1 ms flush**. **Honest scope:** clean links already bypass the encoder (`repair == 0`), so this helps **only the Bulk-under-loss egress path**, not clean-link throughput. Gate: `arq_recovers_bulk_loss` ≥ 98% under batching. Blocked-by review sign-off on the spec's open questions (N, flush deadline, all-or-nothing recovery risk).
vxfemboy commented 2026-07-12 23:49:36 +00:00 (Migrated from github.com)

Obsolete after the FEC codec swap in #50: RaptorQ was replaced by a small-K systematic Reed–Solomon codec (encode ~26 µs → ~1.33 µs). The ~24 µs RaptorQ per-object setup this issue targets no longer exists, so the motivation is gone. Closing.

Obsolete after the FEC codec swap in #50: RaptorQ was replaced by a small-K systematic Reed–Solomon codec (encode ~26 µs → ~1.33 µs). The ~24 µs RaptorQ per-object setup this issue targets no longer exists, so the motivation is gone. Closing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
femboy/yip#27
No description provided.