libnl icon indicating copy to clipboard operation
libnl copied to clipboard

Use recvmmsg() when available

Open socketpair opened this issue 11 years ago • 3 comments

On huge netlink traffic (like ULOG or NFLOG) receiving one message per syscall affect performance. Receiving multiple mesasges at once give preformance boost.

socketpair avatar Sep 28 '12 10:09 socketpair

Note that since commit 55ea6e6b6cd805f441b410971c9dd7575e783ef4, we use recvmsg() with MSG_PEEK by default, which means that for each message two syscalls are required.

thom311 avatar Dec 02 '16 13:12 thom311

:( Did anyone test performance ?

socketpair avatar Dec 04 '16 15:12 socketpair

Not tested, because correctness trumps performance.

To get the previous behavior, call nl_socket_disable_msg_peek() (this also works against older versions of the library). Then it's up to you to ensure that the buffer size is large enough (it's not clear how to do that in the general case).

FWIW, systemd does MSG_PEEK too: https://github.com/systemd/systemd/blob/3099caf2b5bb9498b1d0227c40926435ca81f26f/src/libsystemd/sd-netlink/netlink-socket.c#L337

thom311 avatar Dec 04 '16 19:12 thom311