lxgeek
lxgeek

Reputation: 1814

Which way is faster , when receive a lot of packets?

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?

Upvotes: 1

Views: 47

Answers (1)

Sunil Bojanapally
Sunil Bojanapally

Reputation: 12658

Depends on the receiving application thread processing capability. How?

Assume you have a receive thread polling your mmapped descriptor ring sufficiently fast enough dequeuing the packets from the buffers allowing packets on the interface enqueue it at same pace. In this scenario definitely option 1 is the best.

When it comes to option 2, I feel per packet mmap invokes a system call which I think impacts performance compared to option 1 where you are creating buffer pool in user space at once calling only one mmap restricting to one system call.

Upvotes: 1

Related Questions