Menu

#1047 Don't lower SNDBUF/RCVBUF

v1.0 (example)
closed
None
5
2016-04-10
2016-04-06
No

In the function tcp_connect, SOAP issues setsockopt(sk, SOL_SOCKET, SO_RCVBUF, &len, sizeof(len)), with len defaulting to SOAP_BUFLEN (which happens to be 65536 here). This is less than what the operating system sets as default for the socket, which can mean a performance degradation. Please do not lower socket buffer size(s), only raise them.
Same applies to SNDBUF.

Discussion

  • Robert van Engelen

    Thanks for the feedback.

    1. Your recommendation is under the (mostly false) assumption that larger buffers are always better. The optimal buffer size is determined by throughput and latency. If the latency is low or if throughput is low, a small buffer is just fine. We found that 64K gives a decent performance in most cases, with larger buffers (256K) only giving a marginally better performance or no improvement in common client/server deployments.

    2. You can increase SOAP_BUFLEN (with -DSOAP_BUFLEN=xxx) and recompile all sources!) to optimize performance and increase the default TCP buffer size. See our FAQ on performance optimizations.

     

    Last edit: Robert van Engelen 2016-04-09
  • Robert van Engelen

    • status: open --> closed
    • assigned_to: Robert van Engelen
     
  • Jan Engelhardt

    Jan Engelhardt - 2016-04-09
    1. The assumption here is not that "larger is better", but that "smaller is worse". For example, there are a number of HOWTOs, one of them being for samba, (dated by now, but not so much dated in 2006) which proclaimed the use "sndbuf=8192" as an "improvement", except that it increased the overhead in smbd so much that the network was far from saturated on a bulk transfer. Ever since I noticed what I once ran afoul of, my maxime has been "don't lower default buffer sizes anymore".
     
  • Robert van Engelen

    The SO_SNDBUF size is not 8K unless you change SOAP_BUFLEN to 8K. The SO_SNDBUF size is not affected by WITH_LEAN (WITH_LEAN does not set these socket options).

    The default is 64K, which is a general recommendation by e.g. gridFTP and other higher performance TCP-based xfer tools, with upward of 64K giving only marginal improvements in typical cases. I had found somewhere that the max is 64K on Mac OS X (perhaps this has changed). But on most systems 256K or larger is ignored.

    I will add a soap.sndbuf and soap.rcvbuf size to the upcoming 2.8.31 release to let users configure the SO_SNDBUF and SO_RCVBUF socket options, which will still be set to 64K as the default. Users can change soap.sndbuf and soap.rcvbuf (after the context init). Setting these to zero will omit the setsockopt calls for SO_SNFBUF and/or SO_RCVBUF altogether. Setting to zero is useful for Linux to enable "send buffer autotuning".

     

Log in to post a comment.