Thread: [asio-users] A possible patch to enable sendmmsg / recvmmsg (in progress)
Brought to you by:
chris_kohlhoff
From: Virgilio F. <vir...@gm...> - 2023-01-10 20:27:57
|
I'm finalizing writing a patch that enables sendmmsg / recvmmsg on supported operating systems (Linux, [Free/Net/Open]BDS, AIX, Blackberry QNX Neutrino). The syscalls are implemented in reactive_socket_service backend only (the io_uring backend on Linux does not support sendmmsg / recvmmsg yet). 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 . <code> 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_; </code> The multiple_buffer_sequence implementations has full container support, iterators, and support Mutable and Const buffer sequences. The patch is near a first working version (need to finalize work on handlers yet), but 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 ( full URL: https://github.com/chriskohlhoff/asio/compare/master...virgiliofornazin:asio:feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg ) |
From: Virgilio F. <vir...@gm...> - 2023-01-14 17:25:45
|
I finished the first version of the patch. It's able to send and receive 1 million 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 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 The working code is pushed on my github repository. On Tue, Jan 10, 2023 at 5:27 PM Virgilio Fornazin < vir...@gm...> wrote: > I'm finalizing writing a patch that enables sendmmsg / recvmmsg on > supported operating systems (Linux, [Free/Net/Open]BDS, AIX, Blackberry QNX > Neutrino). > > The syscalls are implemented in reactive_socket_service backend only (the > io_uring backend on Linux does not support sendmmsg / recvmmsg yet). > > 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 . > > <code> > 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_; > </code> > > The multiple_buffer_sequence implementations has full container support, > iterators, and support Mutable and Const buffer sequences. > > The patch is near a first working version (need to finalize work on > handlers yet), but 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 > > ( full URL: > https://github.com/chriskohlhoff/asio/compare/master...virgiliofornazin:asio:feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg > ) > > |
From: Virgilio F. <vir...@gm...> - 2023-01-17 00:52:01
|
The patch is working fine, also implemented support for Apple OS (darwin kernels) using sendmsg_x / recvmsg_x system calls (as pointed on boost mailing list). On a i9 MacBook Pro, https://youtu.be/4bT6zM1VNTU On a m1 Mac Mini, https://youtu.be/Zs22S9GGKRs Sources are on github (I'm updating the branch with newer implementations) On Sat, Jan 14, 2023 at 2:25 PM Virgilio Fornazin < vir...@gm...> wrote: > I finished the first version of the patch. It's able to send and receive 1 > million 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 > > 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 > > The working code is pushed on my github repository. > > > On Tue, Jan 10, 2023 at 5:27 PM Virgilio Fornazin < > vir...@gm...> wrote: > >> I'm finalizing writing a patch that enables sendmmsg / recvmmsg on >> supported operating systems (Linux, [Free/Net/Open]BDS, AIX, Blackberry QNX >> Neutrino). >> >> The syscalls are implemented in reactive_socket_service backend only (the >> io_uring backend on Linux does not support sendmmsg / recvmmsg yet). >> >> 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 . >> >> <code> >> 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_; >> </code> >> >> The multiple_buffer_sequence implementations has full container support, >> iterators, and support Mutable and Const buffer sequences. >> >> The patch is near a first working version (need to finalize work on >> handlers yet), but 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 >> >> ( full URL: >> https://github.com/chriskohlhoff/asio/compare/master...virgiliofornazin:asio:feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg >> ) >> >> |