You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Mike Abbott <mj...@trudge.engr.sgi.com> on 1999/07/21 02:05:05 UTC
[PATCH] 10x performance increase patch #5
Apache Developers,
Here is my fifth patch that increases Apache's performance. This one
eliminates the signal handling associated with graceful restarts.
The inspiration for this patch is the NO_GRACEFUL part of Dean's top
fuel patch
http://www.arctic.org/~dgaudet/apache/1.3/top_fuel.patch
This patch differs from the NO_GRACEFUL part of Dean's patch in that it
eliminates the variables controlling graceful restart too, and the
unnecessary checks of those variables.
This patch also includes the missing SIGUSR1 manipulation in the new
function quickly_read_request_line() (from patch #2). When I was
splitting out patch #2 I accidentally omitted that snippet because it
looked like NO_GRACEFUL stuff which was not relevant at the time.
(Really, I am trying to be careful.)
The base for this patch is Apache/1.3.6 + 10x performance increase
patches #1 through #4.
As always, I welcome your review, questions, and feedback.
--
Michael J. Abbott mja@sgi.com
========================================================================
diff -Naur apache_1.3.6+01-04/htdocs/manual/stopping.html apache_1.3.6+01-05/htdocs/manual/stopping.html
--- apache_1.3.6+01-04/htdocs/manual/stopping.html Mon Mar 22 16:17:35 1999
+++ apache_1.3.6+01-05/htdocs/manual/stopping.html Tue Jul 20 16:25:29 1999
@@ -125,6 +125,11 @@
complete for users on low bandwidth links then you could wait 15 minutes
before doing anything with the old log.
+<P>Supporting graceful restarts slows Apache down somewhat. You can
+increase performance by compiling apache with the
+<CODE>NO_GRACEFUL</CODE> flag, which disables graceful restarts.
+<CODE>USR1</CODE> will behave like <CODE>HUP</CODE>.
+
<P><STRONG>Note:</STRONG> If your configuration file has errors in it when
you issue a
restart then your parent will not restart, it will exit with an error.
diff -Naur apache_1.3.6+01-04/src/include/httpd.h apache_1.3.6+01-05/src/include/httpd.h
--- apache_1.3.6+01-04/src/include/httpd.h Mon Jul 19 16:22:48 1999
+++ apache_1.3.6+01-05/src/include/httpd.h Tue Jul 20 16:26:22 1999
@@ -70,6 +70,7 @@
#ifdef SPEED_DAEMON /* that's me, a real speed demon */
# define FAST_TIME /* eliminate redundant calls to time() */
# define BUFFERED_LOGS /* buffer log messages */
+# define NO_GRACEFUL /* eliminate per-request signal manipulation */
# define USE_QUICK_LOG /* fast path through logging code */
#endif
diff -Naur apache_1.3.6+01-04/src/main/http_main.c apache_1.3.6+01-05/src/main/http_main.c
--- apache_1.3.6+01-04/src/main/http_main.c Tue Jul 20 15:50:49 1999
+++ apache_1.3.6+01-05/src/main/http_main.c Tue Jul 20 16:29:00 1999
@@ -2650,6 +2650,7 @@
}
}
+#ifndef NO_GRACEFUL
static int volatile usr1_just_die = 1;
static int volatile deferred_die;
@@ -2660,6 +2661,7 @@
}
deferred_die = 1;
}
+#endif
/* volatile just in case */
static int volatile shutdown_pending;
@@ -2771,6 +2773,9 @@
}
/* do a graceful restart if graceful == 1 */
+#ifdef NO_GRACEFUL
+/*ARGSUSED*/
+#endif
void ap_start_restart(int graceful)
{
#ifndef WIN32
@@ -2779,7 +2784,9 @@
return;
}
restart_pending = 1;
+#ifndef NO_GRACEFUL
is_graceful = graceful;
+#endif
#else
signal_parent(1); /* get the parent process to wake up */
#endif /* WIN32 */
@@ -3522,6 +3529,9 @@
printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
#endif
#endif
+#ifdef NO_GRACEFUL
+ printf(" -D NO_GRACEFUL\n");
+#endif
#ifdef USE_QUICK_LOG
printf(" -D USE_QUICK_LOG\n");
#endif
@@ -3715,6 +3725,7 @@
BUFF *conn_io;
request_rec *r;
+#ifndef NO_GRACEFUL
/* Prepare to receive a SIGUSR1 due to graceful restart so that
* we can exit cleanly. Since we're between connections right
* now it's the right time to exit, but we might be blocked in a
@@ -3721,6 +3732,7 @@
* system call when the graceful restart request is made. */
usr1_just_die = 1;
signal(SIGUSR1, usr1_handler);
+#endif
/*
* (Re)initialize this child to a pre-connection state.
@@ -3787,17 +3799,21 @@
/* if we accept() something we don't want to die, so we have to
* defer the exit
*/
+#ifndef NO_GRACEFUL
deferred_die = 0;
usr1_just_die = 0;
+#endif
for (;;) {
clen = sizeof(sa_client);
csd = accept(sd, &sa_client, &clen);
if (csd >= 0 || errno != EINTR)
break;
+#ifndef NO_GRACEFUL
if (deferred_die) {
/* we didn't get a socket, and we were told to die */
clean_child_exit(0);
}
+#endif
}
if (csd >= 0)
@@ -3863,6 +3879,7 @@
}
}
+#ifndef NO_GRACEFUL
/* go around again, safe to die */
usr1_just_die = 1;
if (deferred_die) {
@@ -3869,6 +3886,7 @@
/* ok maybe not, see ya later */
clean_child_exit(0);
}
+#endif
/* or maybe we missed a signal, you never know on systems
* without reliable signals
*/
@@ -3880,10 +3898,12 @@
SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
+#ifndef NO_GRACEFUL
/* We've got a socket, let's at least process one request off the
* socket before we accept a graceful restart request.
*/
signal(SIGUSR1, SIG_IGN);
+#endif
ap_note_cleanups_for_fd(ptrans, csd);
@@ -3983,6 +4003,7 @@
clean_child_exit(0);
}
+#ifndef NO_GRACEFUL
/* In case we get a graceful restart while we're blocked
* waiting for the request.
*
@@ -3998,6 +4019,7 @@
*/
usr1_just_die = 1;
signal(SIGUSR1, usr1_handler);
+#endif
}
/*
diff -Naur apache_1.3.6+01-04/src/main/http_protocol.c apache_1.3.6+01-05/src/main/http_protocol.c
--- apache_1.3.6+01-04/src/main/http_protocol.c Mon Jul 19 16:37:55 1999
+++ apache_1.3.6+01-05/src/main/http_protocol.c Tue Jul 20 16:29:55 1999
@@ -833,6 +833,9 @@
cp[7] == '.' &&
(cp[8] == '0' || cp[8] == '1') &&
((cp[9] == '\r' && cp[10] == '\n') || cp[9] == '\n')) {
+#if defined(SIGUSR1) && !defined(NO_GRACEFUL)
+ signal(SIGUSR1, SIG_IGN);
+#endif
r->rqhdr = cp + 10 + (cp[9] == '\r');
r->rqhdr_len = (int) (&r->rqbuf[n] - r->rqhdr);
@@ -909,7 +912,7 @@
}
}
/* we've probably got something to do, ignore graceful restart requests */
-#ifdef SIGUSR1
+#if defined(SIGUSR1) && !defined(NO_GRACEFUL)
signal(SIGUSR1, SIG_IGN);
#endif