From 5c876f67cf9e0bf544d0d0ad0b09b54decaac6d1 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 9 Jan 2013 17:13:38 +0300 Subject: [PATCH] tcpsocket.c: disable Nagle's algorithm for sent commands Sent commands are very short, like "cvs co foo", "cvs co bar". We pair them with large receive commands. The faster we will send them out the faster we will receive the result. Nagle's algorithm does not allow sending requests faster, than 5 checkouts per second. The patch speedups importing my real repository (30 000 checkouts) from 90 minutes down to 5 minutes. It means patch speedups from 5 checkouts to 100 checkouts per second. Signed-off-by: Sergei Trofimovich Signed-off-by: Eric S. Raymond --- tcpsocket.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tcpsocket.c b/tcpsocket.c index f74a09d..72540cd 100644 --- a/tcpsocket.c +++ b/tcpsocket.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,14 @@ tcp_create_socket(int reuse_addr) setsockopt( retval, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(int)); } + yes = 1; + setsockopt (retval, /* socket affected */ + IPPROTO_TCP, /* set option at TCP level */ + TCP_NODELAY, /* name of option */ + (char *) &yes, /* the cast is historical + cruft */ + sizeof(int)); /* length of option value */ + debug(DEBUG_TCP, "tcp: socket created"); #ifdef WIN32 return get_fd(retval, WIN32_SOCKET); -- 2.1.4