SOL_SOCKET/SO_CPUINT socket option

Sepherosa Ziehau sepherosa at gmail.com
Sat Dec 27 00:43:15 PST 2014


Hi all,

SOL_SOCKET/SO_CPUHINT socket option (currently read-only).  This
option gives you the hint about to which CPU the userland process
could be bound to (-1 means no hint).  It's mainly for TCP/UDP server
userland application.  For TCP listen socket, it only makes sense for
TCP listen socket w/ SO_REUSEPORT.

- TCP listen socket w/ SO_REUSEPORT, this socket option should be
extracted after listen(2).
- TCP socket for connect(2), this socket option should be extracted
after connect(2) is successful.
- UDP socket for bind(2), this socket option should be extracted after bind(2).
- UDP socket for connect(2), this socket option should be called after
connect(2).

For TCP listen socket w/ SO_REUSEPORT, binding process to the hinted
cpu avoids >1/3 IPIs between CPUs (24000ipis/s -> 15000ipis/s) during
a accept(2) heavy test (well, I am still hunting the source of the
rest of the IPIs).
For UDP bind socket w/ SO_REUSEPORT, binding process to the hinted cpu
completely avoids IPIs between CPUs.

Hope it will be useful for you.

Best Regards,
sephe

-- 
Tomorrow Will Never Die



More information about the Users mailing list