shunt
kernel-bypass market-data receiver
2026 · in progress · C++ · eBPF/XDP · AF_XDP · libbpf
What it is
A kernel-bypass market-data receiver in C++20. An XDP program steers UDP feed packets toward AF_XDP shared-memory rings, so user space can parse updates, track sequence gaps, and maintain book state without the kernel's socket receive path.
Why
Exchanges publish market data over UDP, and every microsecond in the receive path matters. shunt measures what bypassing the kernel's socket stack actually buys, against a plain UDP-socket receiver handling identical traffic.
How it works
- A binary wire codec, a sequence-gap tracker, and checksummed market state
- A deterministic, seeded feed generator, so every run is reproducible
- A
sendmmsgreplayer with absolute-deadline pacing - A veth pair across two network namespaces as the test link
- An eBPF/XDP feed-port filter loaded through libbpf, attaching in native mode on veth rather than the generic fallback
Results so far
- UDP-socket baseline: 10k messages at 50k packets/s with no loss, p50 123 µs, p99 264 µs.
- The XDP program attaches natively and filters the feed port.
- Next: AF_XDP receive rings, then the same latency sweep against the baseline.
Decisions
- Two builds: a complete, measured copy-mode receiver first, then zero-copy without a rewrite.
- AF_XDP rings will be driven directly through
linux/if_xdp.h, without libxdp. - No zero-copy claims until it runs on hardware that supports it.
- Packet loss under load is recorded as data, not treated as a failure.