mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: Some DatagramChannels are extremely high-throughput. This can occur when UDP is being used as an encapsulation for a transport protocol (e.g. QUIC), or when a highly utilized service is being offered on a single port (e.g. DNS). In these cases, the syscall overhead of datagram reads is quite high (one recvfrom call per datagram). It would be helpful to be able to trade off some memory usage in order to reduce the cost of the syscalls in this situation. This patch adds support for transparently using the recvmmsg syscall to achieve this kind of tradeoff. Modifications: - Added support to the DatagramChannel for issuing vector reads. - Added new ChannelOption: DatagramVectorReadMessageCountOption - Added UDP echo server example to exercise functionality. - Tests Result: Able to achieve higher read throughput on supported systems.