asio icon indicating copy to clipboard operation
asio copied to clipboard

max iovlen on linux when sending buffer sequence

Open avukajlo opened this issue 5 years ago • 3 comments

Asio does not use max iovlen for socket sending (when using buffer sequence send). I am trying to understand rationale behind. Currently in buffer_sequence_adapter there is truncation to only 64 buf len enum { max_buffers = 64 < max_iov_len ? 64 : max_iov_len };

on linux max_iov_len is 1024 if defined (IOV_MAX) const int max_iov_len = IOV_MAX; else ... and on my linux it is 1024

define __IOV_MAX 1024

Is it possible to configure max_buffers externally, or just use IOV_MAX.

Another question. There are helpers (consuming_buffers and prepared_buffers) used when doing sending buf sequence. I know that I can implement my helpers, but do not understand rationale behind, why in those implementation buffers sequence is reduced to only 16 buffers

look at consuming_buffers.hpp enum { max_buffers = MaxBuffers < 16 ? MaxBuffers : 16 };

This can lead to performance drop when sending large number of small buffers, when using boost::asio::async_send function.

avukajlo avatar Sep 28 '20 19:09 avukajlo

+1. Please @chriskohlhoff Help us.

IronsDu avatar Jan 27 '21 14:01 IronsDu

when I mannualy change max_buffers to 1024 (assumes also change in consuming_buffers) I got much better throughput on scatter sending small buffers. It is "ugly" for me to change it in asio directly. One drawback of large vector size (for example 1024) is large memory for allocating handler (I use it with custom alloc). Maybe this memory usage was rationale behind small vector size in scatter write but ... it works for my use case. It would be nice to have max_iov_len configurable somehow.

avukajlo avatar Jan 30 '21 13:01 avukajlo

I try to test pipeline performance, and if small buffers count > 16, performance drop seriously. At least we should mention it in document.

poor-circle avatar Apr 24 '22 08:04 poor-circle