Benchmarking AF_XDP Zero-Copy Descriptors Against Kernel Sockets
For custom telemetry ingress, standard BSD socket APIs hit a hard scaling wall around 1.8M packets per second per core due to memory allocation, socket locks, and cache thrashing in __netif_receive_skb.
AF_XDP bypasses the entire kernel network stack by delivering raw frames directly from the NIC DMA ring into user-space memory buffers (UMEM). In our zero-copy driver implementation (Intel i40e), single-core throughput climbed from 1.62M pps to 14.88M pps at 64-byte frame sizes, with CPU utilization dropping from 100% to 38%.
// XDP socket bind configuration
struct sockaddr_xdp sa = {
.sxdp_family = PF_XDP,
.sxdp_ifindex = ifindex,
.sxdp_queue_id = queue_id,
.sxdp_flags = XDP_ZEROCOPY,
};
The primary engineering trade-off is memory footprint: pre-allocating dedicated UMEM rings for multiple queues requires careful NUMA node alignment to prevent cross-socket UPI traffic.