Hard
Setting SO_BUSY_POLL on a market-data socket
A market-data feed handler currently blocks in epoll_wait() on its UDP socket. Under load, p99 latency from 'packet arrives on the NIC' to 'application processes it' is dominated by wakeup jitter rather than by the packet processing itself: the delay of an interrupt, softirq, and scheduler wakeup pulling the blocked thread off a run queue. The team sets SO_BUSY_POLL on the socket as shown. What does this actually change, and what does it cost?
feed.cpp
#include <sys/socket.h>
#include <cstdio>
void enable_busy_poll(int sockfd, int usecs) {
if (setsockopt(sockfd, SOL_SOCKET, SO_BUSY_POLL, &usecs, sizeof(usecs)) != 0) {
perror("setsockopt SO_BUSY_POLL");
}
}
// enable_busy_poll(sockfd, 50); // busy-poll for up to 50us before blocking42 of 53 in Operating Systems