|
Boost : |
From: Virgilio Fornazin (virgiliofornazin_at_[hidden])
Date: 2023-01-14 18:41:20
As stated on asio-users mailing list (
https://sourceforge.net/p/asio/mailman/asio-users/thread/CADfydx%2BDF1kvqchV_heJ0TvzTT17MT5MrmArL5Zf_Wy1%2BFQRKw%40mail.gmail.com/#msg37760284
), I wrote a patch that enables sendmmsg / recvmmsg on supported operating
systems (Linux, [Free/Net/Open]BDS, AIX, Blackberry QNXNeutrino).
The syscalls are implemented in reactive_socket_service backend (the
io_uring backend on Linux does not support sendmmsg / recvmmsg yet, so no
recvmmsg / sendmmsg when using newest support for io_uring on asio).
The config.hpp has macros for forcible disable those calls, and detect
supported operating system compiler macros.
New methods were developed for (send/send_to/receive/receive_from) suffixed
with '_multiple_buffer_sequence' that accepts a multiple_buffer_sequence
class (backed by asio::detail::array<multiple_buffer_sequence_op, N> or
std::vector<multiple_buffer_sequence_op>) and a
multiple_buffer_sequence_adapter that convert ops to struct mmsghdr* for
sendmmsg/recvmmsg.
The multiple_buffer_sequence implementations are basically a collection of
multiple_buffer_sequence_op instances that represents each socket operation
.
It defines the objects needed to perform fill on mmsghdr structures
buffer_sequence_type buffer_sequence_;
buffer_sequence_adapter_type buffer_sequence_adapter_;
endpoint_type endpoint_;
bool completed_;
socket_base::message_flags flags_;
std::size_t bytes_transferred_;
asio::error_code error_code_;
The multiple_buffer_sequence implementations has full container support,
iterators, and support Mutable and Const buffer sequences.
I finished the first version of the patch. It's able to send and receive
1million packet / second on my box at same time (an intel i9 9900k / ubuntu
22.04 lts low latency kernel) using packet sizes of 64 / 1430 bytes without
packet loss (using 64mb udp socket buffers)
A little running demo is able to being watched at
https://www.youtube.com/watch?v=Q3hqe6ntM3w. I need to write some automatic
tests for (async_)[send/receive]_multiple_buffer_sequence calls[_to/_from]
and push a pure ASIO example in examples repository
I made the code available for review, scrutiny and suggestions.
The source code is in my github repo (
https://github.com/virgiliofornazin/asio ),on branch
feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg
( the full URL of patch diff is
https://github.com/chriskohlhoff/asio/compare/master...virgiliofornazin:asio:feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg
).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk