Which way is faster , when receive a lot of packets?
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Mon Aug 25 09:48:46 EDT 2014
On Mon, 25 Aug 2014 20:30:00 +0800, lx said:
> I have two ideas to handle the packet.
> 1.I allocate a memory pool and mmap into userspace, when packet is coming,
> I copy packet into the memory pool, then, userspace can access it.
> 2.When packet is coming , I mmap the data of packet into userspace every
> time, then userspace can access this packet.
> Which one is better, why?
Hint: mmap is expensive, you don't want to do it on every packet when the
packets are showing up at 100K/second.
You might want to see which way do the 10G ethernet drivers do it? If you're an
NFS server trying to flip 100K packets a second *plus* do the disk I/O, making
it as cheap as possible is really important. Also, look carefully how existing
drivers actually implement zero-copy (it's trickier than it looks)
Also, if you're trying to flip packets fast, you forgot:
MTU=9000 if your network setup allows it - that gets you a 6x reduction in
interrupts on bulk transfers.
Interrupt coalescing, where the card doesn't even bother waking you up on
every packet.
You'll also want to be looking at hardware that does TSO/GSO, at 10G you'll
be wanting to offload as many processing cycles as you can....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140825/a84d95d3/attachment.bin
More information about the Kernelnewbies
mailing list