[PATCH] Receive multiple packets at a time

Guus Sliepen guus at tinc-vpn.org
Wed Dec 2 13:53:37 CET 2015


On Wed, Dec 02, 2015 at 12:58:26PM +0100, Samuel Thibault wrote:

> Linux has a recvmmsg() system call which allows to achieve several
> recvfrom() at a time.  The patch below makes tinc use it (patch against
> 1.1-pre11). Basically the patch turns the handle_incoming_vpn_data
> variables into arrays (of size 1 when recvmmsg is not available, and
> thus compiled the same as before), and makes the code index into the
> arrays. You may want to use interdiff -w /dev/null patch to better see
> what changes the patch makes.
> 
> With this patch, I saw the non-ciphered bandwidth achieved over direct
> ethernet improve from 680Mbps to 800Mbps (or conversely, reduce the CPU
> usage for the same bandwidth).

That's great! It would be good though to split
handle_incoming_vpn_data() into a function that does the actual
recvfrom/mmsg() and one that processes each individual packet, to reduce
the level of indentation and make the functions a bit more readable.
Then I'll merge it :)

I guess in the future, we want to put a "cork" on the output until all
packets from a single recvmmsg() have been received, so that we can do
sendmmsg() on the resulting outgoing packets.

> More is yet to come: I'll have a look at extending the tun/tap interface
> to send/receive several packets at a time, and then also using sendmmsg
> will again improve performance.

Last time I checked, the send/recvmmsg() functionality is actually there
in the kernel code, but just not exposed to userspace. It would be great
to have access to it though.

-- 
Met vriendelijke groet / with kind regards,
     Guus Sliepen <guus at tinc-vpn.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.tinc-vpn.org/pipermail/tinc-devel/attachments/20151202/bcacc364/attachment-0001.sig>


More information about the tinc-devel mailing list