TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25603 14
AFXDP implementation in C++ plus benchmarks against DPDK on real NICs

I developed a C++ library which implements AF\
XDP and DPDK as backends for latency critical network processing tasks. I notice there are only few benchmarks comparing AF_XDP against DPDK on the same NICs therefore I aim to fill this gap. I used C++20 since that is my strongest language and it interfaces nicely with the low-level driver or linux kernel code.

The AF_XDP implementation is here: https://github.com/ASherjil/ABTRDA3/blob/master/src/backends/AF\_XDP/AFXDP.hpp


The comprehensive benchmark 24h results are here:

https://github.com/ASherjil/ABTRDA3/blob/master/docs/Benchmarks.md

One point that I think is underappreciated: a commonly marketed advantage of AF_XDP is that it doesn't unbind the NIC driver, so the interface stays visible to ip link and ethtool. That's true for Intel NICs, where DPDK requires binding to vfio-pci. But it's not true for mlx5 (ConnectX-4/5/6/7), which is a bifurcated driver — the NIC stays fully visible to the kernel while DPDK runs. On Mellanox hardware, the main practical argument for AF_XDP largely disappears.

On implementation effort: even with libbpf and libxdp, custom AF_XDP has high code complexity and plenty of driver-specific quirks. Its four lock-free SPSC rings (fill/RX/TX/completion) are counterintuitive and fairly difficult to comprehend. Without the helper libraries I'd call it a serious long-term project. For most use cases I'd recommend DPDK's AF_XDP PMD instead of a from-scratch implementation — in my results, my custom implementation performed only marginally better than DPDK’s AF_XDP PMD. I've documented the driver specific issues in the repository.

Let me know if you guys have any feedback about the code, bench-marking methodology or anything else. Or any questions I'm happy to answer I don't really mind.

https://redd.it/1uub2kx
@r_cpp
GitHub ABTRDA3/src/backends/AF_XDP/AFXDP.hpp at master · ASherjil/ABTRDA3 A low latency deterministic networking library developed with backends: DPDK, AF_XDP and Packet_MMAP. - ASherjil/ABTRDA3
More from @r_cpp
  1. Sep 26, 2026Token Sequence Injection & Modern Macros: The Most Game-Changing Compile-Time Feature in C…
  2. Sep 25, 2026myStringStream.str("") Considered Harmful Under C++20 I was recently looking at some (rath…
  3. Sep 20, 2026A clever branch free optimization I'm the developer of memlz which is an extremely fast co…
  4. Sep 15, 2026Inside Boost.PolyCollection https://bannalia.blogspot.com/2026/09/inside-boostpolycollecti…
  5. Sep 11, 2026C++26: Standard Library Hardening Experiments https://www.cppstories.com/2026/hardening-ex…
  6. Sep 11, 2026MSVC C++23: constexpr cmath with LLVM Libc https://devblogs.microsoft.com/cppblog/msvc-c23…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →