Skip to content

perf(fec): accelerate GF multiply-add with SIMD - #330

Merged
davidtorcivia merged 5 commits into
mainfrom
codex/fec-nibble-kernel
Aug 19, 2026
Merged

davidtorcivia merged 5 commits into
mainfrom
codex/fec-nibble-kernel

Conversation

@davidtorcivia

@davidtorcivia davidtorcivia commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Objective

Remove the GF(2^8) multiply-add CPU ceiling from FEC while preserving the frozen wire field and a safe scalar fallback.

Changes

  • unroll the product-table fallback eight bytes at a time
  • add runtime-dispatched AVX2 and AArch64 NEON nibble-table kernels through a safe target-feature token
  • preserve the coefficient-one direct XOR path
  • keep unsupported targets on the exact scalar implementation; the target-scoped dependency has no transitive runtime dependencies
  • check every coefficient and byte value across scalar, dispatched, vector-sized, empty, and awkward-tail lengths
  • correct the stale FEC-default statement in ADR-0039

Kernel measurements

Local Intel i5-13500, release, 1 KiB symbols:

  • GF multiply-add: 4.98 GB/s scalar median to 42.44 GB/s AVX2 median (8.5x)
  • decode one missing source: 27.7 us to 18.4 us median (34% lower)
  • decode eight missing sources: 118.4 us to 36.1 us median (70% lower)
  • coefficient-one XOR remains a separate ~70.6 GB/s fast path

Live WAN

Stacked with #329 on Hetzner Helsinki to Singapore, 191.8ms RTT, 5% bidirectional loss, exact 12 GiB object, eight rails:

  • adaptive-default FEC engaged: 84,798 epochs offered, 62,331 coded, 45,255 decoded, zero abandoned or refused
  • candidate FEC: 100.449s versus reliable candidate 106.744s (5.9% faster)
  • candidate FEC: 100.449s versus main FEC 103.456s (2.9% faster)
  • receiver CPU: 170.5 versus 174.5 CPU-seconds on main (2.3% lower)
  • first payload: 1.672s versus 3.191s on main (47.6% lower)
  • exact root and 12 GiB byte count verified in clean, reliable-loss, and adaptive-FEC runs

The temporary CPX32 hosts exposed AVX2 and AVX-512; this change dispatched AVX2. Hetzner had no CAX capacity in fsn1, nbg1, or hel1, so NEON has cross-target/CI coverage but no runtime measurement in this PR.

Validation

  • cargo test -p vot-fec (31 passed, 2 measurement tests ignored)
  • strict native and wasm Clippy
  • Windows x86_64 check and wasm scalar fallback check
  • locked frame-codec and manifest fuzz builds
  • dependency-boundary and SDK-dependency checks
  • seven stabilized release kernel runs: 40.59, 42.44, 41.90, 43.09, 41.03, 42.59, 42.86 GB/s

Process eight independent table lookups per loop iteration so the CPU can overlap their latency. This preserves the scalar fallback and exact field products while improving the release kernel median from 4.11 to 4.98 GB/s.

Signed-off-by: David Torcivia <david.torcivia@gmail.com>
Signed-off-by: David Torcivia <david.torcivia@gmail.com>
Signed-off-by: David Torcivia <david.torcivia@gmail.com>
Signed-off-by: David Torcivia <david.torcivia@gmail.com>
Signed-off-by: David Torcivia <david.torcivia@gmail.com>
@davidtorcivia
davidtorcivia force-pushed the codex/fec-nibble-kernel branch from 53aa86e to 7e8dc0f Compare August 19, 2026 05:35
@davidtorcivia

Copy link
Copy Markdown
Contributor Author

Independent exact-head review at 7e8dc0fd70c77f802187b84d24b4a88f731bc8f9: clean. AVX2/NEON math, runtime dispatch, scalar fallback, coefficient-one XOR, exhaustive coefficient/byte/tail coverage, target-scoped dependency audit, locked fuzz metadata, and ADR correction were verified. No actionable blockers.

@davidtorcivia
davidtorcivia marked this pull request as ready for review August 19, 2026 05:37
@davidtorcivia
davidtorcivia merged commit 17160ae into main Aug 19, 2026
6 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant