I have been tinkering with an open source project that has started making use of asynchronous overlapped IO for sending data using the Winsock2 interfaces in one of its most recent versions. In the project's past, one approach to improve the send performance of (old) blocking/synchronous IO has been to increase the sendbuffer size (SO_SNDBUF) to the size of the packets to be sent (using the send() function). With the introduction of overlapped IO (using the WSASend() function) this feels less sensible to me. I read the documentation and thought setting SO_SNDBUF to 0 might actually help save some resources but I ended up just slowing down the sending process.
Now, despite some research I could not find any description of how WSASend() and overlapped non-blocking IO actually handles the internal socket buffer. Will it take the provided array of WSABUF structures and push in as much data as it can into the internal send buffer (i.e. multiple WSABUF, some of which might become split) every once in a while? Or will it only try and push a single WSABUF into the buffer (splitting the WSABUF if the internal buffer is too small) at a time?
Taking it from there: How reasonable is it to increase the SO_SNDBUF to the size of the largest WSABUF that can be expected when using asynchronous overlapped IO? This would obviously increase the memory utilisation of the application but I am assuming this won't be an issue for the time being because I will only ever have a couple of dozen sockets open with increased SO_SNDBUF and we are talking about threefold the original size.
Thanks for your input!