Linux Application Programming for Network Throughput
New Programming Techniques
There are a number of programming techniques that help improve network throughput and reduce CPU requirements. Besides the commonly used use of pthreads and parallel streams used by tests tools like iperf2/iperf3 and many data transfer tools, this page summarizes some other options to be aware of.
MSG_ZEROCOPY
MSG_ZEROCOPY is a Linux-specific socket option introduced in kernel version 4.14 to enable zero-copy transmission of data over sockets. It is designed to improve performance and reduce CPU load in high-throughput applications by reducing the overhead of copying data between user space and kernel space.
See: https://www.kernel.org/doc/html/v4.18/networking/msg_zerocopy.html
Note that iperf3 does not yet support MSG_ZEROCOPY, but there is a patch for MSG_ZEROCOPY support that can be found here.
io_uring
io_uring is a Linux kernel feature introduced in version 5.1 that provides high-performance asynchronous I/O. It improves network throughput by reducing the overhead and latency associated with traditional system calls and blocking I/O operations.
For more information, see: https://unixism.net/2020/04/io-uring-by-example-article-series/