How can I reduce system call overhead when sending

2019-06-27 19:09发布

For example, I am sending 100000 UDP packets on Windows. For each packet, I need to call WSASendTo() once, so probably a lot of system call overhead is introduced. Is there a way to do bulk sending and reduce this overhead? I could not find a solution for Windows after googling for a while. Also, I would like to know if this is possible on Linux. Thanks.

2条回答
混吃等死
2楼-- · 2019-06-27 19:51

On Windows you can use the new Windows Registered I/O API (RIO) on Server 2012 and Windows 8 and later.

I've written quite a lot about it here and have done several performance comparisons with the previous APIs that are available on Windows. The performance tests can be found here.

In summary: "The Registered I/O Networking Extensions, RIO, is a new API that has been added to Winsock to support high-speed networking for increased networking performance with lower latency and jitter. These extensions are targeted primarily for server applications and use pre-registered data buffers and completion queues to increase performance. The increased performance comes from avoiding the need to lock memory pages and copy OVERLAPPED structures into kernel space when individual requests are issued, instead relying on pre-locked buffers, fixed sized completion queues, optional event notification on completions and the ability to return multiple completions from kernel space to user space in one go."

The results of my performance tests seem to imply that it works.

查看更多
贼婆χ
3楼-- · 2019-06-27 19:52

Use TransmitPackets() in Windows.

查看更多
登录 后发表回答