Hi,
the default maximum size of the tcp send and receive buffer used by the
autosizing algorithm is way too small, when trying to get maximum speed with
high bandwidth and high latency connections.
I tested to get the best speed with a connection between Germany and Canada,
ping times around 180ms.
On the site in Germany, I have 155MBit Internet uplink, but the card in the
test box, only negotiated 100MBit, so actually 100MBit uplink to the Internet.
(Why it only negotiated 100MBit, is not the topic here...)
On the site in Canada, I have even more than 155MBit Internet uplink.
The maximum size of the buffer is defined in sys/sys/socketvar.h:
#define SB_MAX (256*1024)
With this value, I got download speeds, downloading on the Canadian box from
the host in Germany, average of about 1.5MB/s, which is definitely not optimal.
Doubling the value (512*1024), I got average speeds around 2.5-3MB/s.
Doubling the value again to (1024*1024) I got average speeds of about 5-6MB/s.
Doubling the value again to (2048*1024) I got average speeds of about 8MB/s.
On the same box in Germany, I had a second harddisk with Linux OpenSUSE 11.2
installed. There, even with tweaking the buffers, I never got more than 4 MB/s
average transfer speed. But that may be because I did not found the right
values to use.
The tcp buffer autosizing algorithm is at the end of sys/netinet/usrreq.c.
As far as I understand the comments and the code right, it should be safe to
raise the value.
The buffer size is scaled up and down, depending on its fill level, and if the
receiver can ack
packets in a given time. Also, in case of low memory, the buffer is reset to
small value.
Therefore I think it should also be safe on busy servers with many connections
on high speed LANs.
But since I'm by far not a network stack expert, I might missing something.
so the patch raises SB_MAX to (2048*1024) which seemed to be the best for my
use case so far. I also tested higher values, but that did not gained me
anything. I did not found a good network card that has gigabit, and good
transfer rates, so I was unable to utilize the full 155MBit on my side here in
Germany. so the value I propose might still be too small for even faster
connections.
so please test, comment, or even OK?
cheers,
Sebastian
Index: sys/sys/socketvar.h
===================================================================
RCS file: /cvs/src/sys/sys/socketvar.h,v
retrieving revision 1.50
diff -u -r1.50 socketvar.h
--- sys/sys/socketvar.h 4 Jul 2011 22:53:53 -0000 1.50
+++ sys/sys/socketvar.h 4 Dec 2011 11:29:58 -0000
@@ -104,7 +104,7 @@
short sb_flags; /* flags, see below */
u_short sb_timeo; /* timeout for read/write */
} so_rcv, so_snd;
-#define SB_MAX (256*1024) /* default for max chars in
sockbuf */
+#define SB_MAX (2048*1024) /* default for max chars in
sockbuf */
#define SB_LOCK 0x01 /* lock on data queue */
#define SB_WANT 0x02 /* someone is waiting to lock */
#define SB_WAIT 0x04 /* someone is waiting for
data/space */