httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@zyzzyva.com>
Subject TCP performance patches
Date Sun, 21 Jul 1996 21:04:13 GMT

Looks like we are going to take a slightly different approach
on the ISI_NOFLUSH_HEADERS code. What about the other changes?
Is this something that can be commited now?


------- Forwarded Message
>From John Heidemann:
- ----------------------------------------------------------------------
- --- ../../apache_1.1b4_pure/src/http_protocol.c	Mon Jun 17 13:55:25 1996
+++ http_protocol.c	Mon Jul  8 17:19:27 1996
@@ -734,8 +734,20 @@
 
     bputs("\015\012",fd);
 
+#ifdef ISI_NOFLUSH_HEADERS
+    /*
+     * Flushing the output stream at this point sends a sub-size
+     * segment.  Sub-size segments interact poorly with BSD-TCP's
+     * slow-start and delayed acknowledgment algorithms, resulting
+     * in a delayed acknowledgment of a later packet and therefore
+     * up to 200ms additional delay.  Avoid this problem by not
+     * flushing the stream.
+     * -John Heidemann <johnh@isi.edu>
+     */
+#else /* ! ISI_NOFLUSH_HEADERS */
     if (c->keepalive)
 	bflush(r->connection->client);  /* For bugs in Netscape, perhaps */
+#endif /* ISI_NOFLUSH_HEADERS */
 
     bsetopt(fd, BO_BYTECT, &zero);
     r->sent_bodyct = 1;		/* Whatever follows is real body stuff... */
- --- ../../apache_1.1b4_pure/src/http_main.c	Thu Jun 13 13:33:02 1996
+++ http_main.c	Sat Jun 29 02:21:09 1996
@@ -104,6 +104,10 @@
 #include <sys/audit.h>
 #include <prot.h>
 #endif
+#ifdef ISI_NO_NAGLE
+#include <netinet/tcp.h>
+#endif /* ISI_NO_NAGLE */
+
 
 /*
  * Actual definitions of config globals... here because this is
@@ -1115,6 +1119,28 @@
     return conn;
 }
 
+#ifdef ISI_NO_NAGLE
+void
+sock_disable_nagle(int s)
+{
+	/*
+	 * The Nagle algorithm says that we should delay sending partial
+	 * packets in hopes of getting more data.  We don't want to do
+	 * this; we are not telnet.  There are bad interactions between
+	 * P-HTTP and Nagle's algorithm that have very severe performance
+	 * penalties.  (Failing to do disable Nagle is not much of a
+	 * problem with simple HTTP.)  A better description of these
+	 * problems is in preparation; contact me for details.
+ 	 * -John Heidemann <johnh@isi.edu>.
+	 *
+	 * In spite of these problems, failure here is not a shooting offense.
+	 */
+	const int just_say_no = 1;
+	if (0 != setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no, sizeof(just_say_no)))
+		fprintf(stderr,"httpd: could not set socket option TCP_NODELAY.\n");
+}
+#endif /* ISI_NO_NAGLE */
+
 /*****************************************************************
  * Child process main loop.
  * The following vars are static to avoid getting clobbered by longjmp();
@@ -1215,7 +1241,21 @@
 	    log_unixerr("getsockname", NULL, NULL, server_conf);
 	    continue;
 	}
- -	
+
+#ifdef ISI_NO_NAGLE
+	sock_disable_nagle(csd);
+#endif /* ISI_NO_NAGLE */
+
+#ifdef ISI_SOCKOPT
+	/* for debugging */
+{
+	int size, sizelen = sizeof(size), e;
+	if (0 == (e = getsockopt(csd, IPPROTO_TCP, TCP_NODELAY, &size, &sizelen))) {
+		fprintf(stderr, "getsockopt: TCP_NODELAY = %d, (response size=%d\n", size, sizelen);
+	} else fprintf(stderr, "getsockopt: return=%d, errno=%d\n", e, errno);
+}
+#endif /* ISI_SOCKOPT */
+
 	(void)update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL);
 	conn_io = bcreate(ptrans, B_RDWR);
 	dupped_csd = csd;
@@ -1311,6 +1351,10 @@
         fprintf(stderr,"httpd: could not set socket option SO_KEEPALIVE\n"); 
         exit(1); 
     }
+
+#ifdef ISI_NO_NAGLE
+    sock_disable_nagle(s);
+#endif /* ISI_NO_NAGLE */
 
 #ifdef NEED_LINGER   /* If puts don't complete, you could try this. */
     {

------- End of Forwarded Message




Mime
View raw message