Bug 542401 - Look into whether Firefox should set TCP_NODELAY for non-SSL HTTP socket r=jduell
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 08 Apr 2011 14:36:56 -0400
changeset 67710 af0342b4004d10c626a69e1aba0105bff2ce9c67
parent 67709 198b15a6543283696599bcd6f3640ace0c8b82bc
child 67711 e48f48ad28be17759eebde37609b5e60fe8add0a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs542401
milestone2.2a1pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 542401 - Look into whether Firefox should set TCP_NODELAY for non-SSL HTTP socket r=jduell indeed without nagle disabled (which is what nodelay does) a pipeline can be interrupted for a full rtt waiting for an ack, which defeats the purpose of pipelining. Other parts of FF can just coalesce the writes internally, but sometimes that is not possible for pipelines which may not have an opportunity for a pipelined request when the "runt" packet goes out, but discovers such an opportunity a long time before the rtt is expired. In other places (such as long posts) we do a fine job of coalescing already, so this should not result in any extra packets on the wire, just improved latency.
netwerk/base/src/nsSocketTransport2.cpp
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -1117,16 +1117,23 @@ nsSocketTransport::InitiateSocket()
 
     // Make the socket non-blocking...
     PRSocketOptionData opt;
     opt.option = PR_SockOpt_Nonblocking;
     opt.value.non_blocking = PR_TRUE;
     status = PR_SetSocketOption(fd, &opt);
     NS_ASSERTION(status == PR_SUCCESS, "unable to make socket non-blocking");
 
+    // disable the nagle algorithm - if we rely on it to coalesce writes into
+    // full packets the final packet of a multi segment POST/PUT or pipeline
+    // sequence is delayed a full rtt
+    opt.option = PR_SockOpt_NoDelay;
+    opt.value.no_delay = PR_TRUE;
+    PR_SetSocketOption(fd, &opt);
+
     // if the network.tcp.sendbuffer preference is set, use it to size SO_SNDBUF
     // The Windows default of 8KB is too small and as of vista sp1, autotuning
     // only applies to receive window
     PRInt32 sndBufferSize;
     gSocketTransportService->GetSendBufferSize(&sndBufferSize);
     if (sndBufferSize > 0) {
         opt.option = PR_SockOpt_SendBufferSize;
         opt.value.send_buffer_size = sndBufferSize;