multi-ev_loop on UDP socket

Brandon Black blblack at
Mon Jun 4 19:45:23 CEST 2012

On Mon, Jun 4, 2012 at 12:36 PM, Brandon Black <blblack at> wrote:
> But you can scale up to more packets/sec handled on a given machine by
> doing one thread-per-socket (-per-core) and distributing the packets

I forgot to mention in the previous email: another area to look at for
high performance UDP on Linux is the relatively new syscalls
sendmmsg() and recvmmsg().  These can send or receive multiple UDP
packets in a single syscall.  This reduces the syscall overhead
(you're bouncing out to kernel space less often and picking/dropping
packets in batches), which further improves the performance of looping
on a single socket.  In theory, it could reduce internal kernel
overhead as well (e.g. lock the socket once for all packets), but last
I checked a lot of those kernel-internal optimizations haven't yet
been implemented; it more less just loops over sendmsg() internally in
the kernel.  By using this interface you'll get them if they ever are,
though.  Just killing some syscall overhead for now is still a nice

-- Brandon

More information about the libev mailing list