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/11/03 22:51:01 UTC

[PATCH] 10x performance increase patch #9

Apache Developers,

Here is my ninth of ten patches for increasing Apache's performance.
This one includes miscellaneous performance tweaks, a new command line
option to facilitate debugging, and a guide to achieving Apache's best
performance on the SPECweb96 benchmark.  It also gives credit to my
employer and myself, as stipulated in my introduction to these patches.

The base for this patch is Apache/1.3.6 + 10x performance increase
patches #1 through #8.  After I contribute the final patch I'll port all
my patches to the latest Apache release.

Note that this patch includes two new files,
htdocs/manual/misc/perf-mja.html and htdocs/sgi_performance.gif.uu.  The
latter must be uudecoded to create the new file
htdocs/sgi_performance.gif.  When I apply the patch to a pure 1.3.6 tree
my version of the patch command puts these files in the current
directory rather than where they belong.  I hope yours works!

As always, I welcome your review, questions, and feedback.
--
Michael J. Abbott        mja@sgi.com        http://reality.sgi.com/mja

========================================================================

diff -Naur apache_1.3.6+01-08/ABOUT_APACHE apache_1.3.6+01-09/ABOUT_APACHE
--- apache_1.3.6+01-08/ABOUT_APACHE	Sat Feb 13 18:30:47 1999
+++ apache_1.3.6+01-09/ABOUT_APACHE	Wed Oct 20 16:39:42 1999
@@ -104,7 +104,8 @@
    
 Other major contributors
 
-   Howard Fear (mod_include), Florent Guillaume (language negotiation),
+   Mike Abbott (performance), Howard Fear (mod_include),
+   Florent Guillaume (language negotiation),
    Koen Holtman (rewrite of mod_negotiation),
    Kevin Hughes (creator of all those nifty icons),
    Rasmus Lerdorf (mod_info, mod_php, mod_php3),
diff -Naur apache_1.3.6+01-08/conf/httpd.conf-dist apache_1.3.6+01-09/conf/httpd.conf-dist
--- apache_1.3.6+01-08/conf/httpd.conf-dist	Thu Sep  2 10:12:04 1999
+++ apache_1.3.6+01-09/conf/httpd.conf-dist	Wed Oct 20 16:39:51 1999
@@ -160,7 +160,7 @@
 # isn't really needed, but a few (such as Solaris) do have notable leaks
 # in the libraries.
 #
-MaxRequestsPerChild 30
+MaxRequestsPerChild 0
 
 #
 # Listen: Allows you to bind Apache to specific IP addresses and/or
diff -Naur apache_1.3.6+01-08/htdocs/index.html apache_1.3.6+01-09/htdocs/index.html
--- apache_1.3.6+01-08/htdocs/index.html	Wed May 20 07:59:42 1998
+++ apache_1.3.6+01-09/htdocs/index.html	Wed Oct 20 16:40:02 1999
@@ -47,5 +47,9 @@
   <DIV ALIGN="CENTER">
    <IMG SRC="apache_pb.gif" ALT="">
   </DIV>
+  <HR>
+  <DIV ALIGN="CENTER">
+   <A HREF="http://www.sgi.com"><IMG SRC="sgi_performance.gif" ALT="" BORDER=0></A>
+  </DIV>
  </BODY>
 </HTML>
diff -Naur apache_1.3.6+01-08/htdocs/manual/invoking.html apache_1.3.6+01-09/htdocs/manual/invoking.html
--- apache_1.3.6+01-08/htdocs/manual/invoking.html	Mon Mar 22 16:17:34 1999
+++ apache_1.3.6+01-09/htdocs/manual/invoking.html	Wed Oct 20 16:40:18 1999
@@ -129,6 +129,10 @@
 <DD>Windows only: signal Apache to restart or shutdown. <EM>option</EM> 
 is one of "shutdown" or "restart". (Apache 1.3.3 and later).
 
+<DT><CODE>-i</CODE>
+<DD>For testing:  Do not daemonize (i.e., do not fork and exit on startup).
+(Apache 1.3.X and later.)
+
 <DT><CODE>-?</CODE>
 <DD>Print a list of the httpd options, and then exit (up to Apache
 1.3.3. Later version use -h instead).
diff -Naur apache_1.3.6+01-08/htdocs/manual/misc/perf-mja.html apache_1.3.6+01-09/htdocs/manual/misc/perf-mja.html
--- apache_1.3.6+01-08/htdocs/manual/misc/perf-mja.html
+++ apache_1.3.6+01-09/htdocs/manual/misc/perf-mja.html	Wed Nov  3 10:28:37 1999
@@ -0,0 +1,409 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+    <META NAME="Generator" CONTENT="Cosmo Create 1.0.3">
+    <TITLE>Making Apache Ten Times Faster</TITLE>
+</HEAD>
+<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
+<BODY ALINK="#ff0000" VLINK="#000080" LINK="#0000ff" BGCOLOR="#ffffff"
+ TEXT="#000000">
+<P>
+<DIV ALIGN="CENTER"><IMG SRC="../images/sub.gif"
+ ALT="[APACHE DOCUMENTATION]"> </P>
+<H3>
+Apache HTTP Server Version 1.3 </H3>
+<P>
+</DIV></P>
+<CENTER><H1 ALIGN="CENTER">
+Making Apache Ten Times Faster</H1>
+</CENTER><CENTER><P ALIGN="CENTER">
+<A HREF="http://reality.sgi.com/mja">Mike Abbott</A> - <A
+ HREF="mailto:mja@sgi.com">mja@sgi.com</A></P>
+</CENTER><HR>
+<P>
+I have contributed <A
+ HREF="http://reality.sgi.com/mja/apache/index.html">ten patches</A> to 
+the Apache Project that together increase the performance of the Apache
+HTTP server up to 900%. This document summarizes how to maximize the
+performance of Apache using my patches. The measure of performance in
+this document is the <A HREF="http://www.spec.org/osg/web96/">SPECweb96
+benchmark</A>, which measures only the number of static HTTP/1.0 GET
+requests a web server can service per second. This paper assumes a
+working knowledge of Apache internals.</P>
+<BLOCKQUOTE>
+<EM>The advice that follows may or may not apply to your system and may
+increase or decrease your system's performance depending on factors
+beyond the scope of this document. Use this guide only in conjunction
+with a clear understanding of your performance goals and overriding
+needs.</EM></BLOCKQUOTE>
+<H2>
+Contents</H2>
+<UL>
+    <LI>
+    <A HREF="#introduction">Introduction</A> 
+    <LI>
+    <A HREF="#qsc">Tuning the QSC</A> 
+    <LI>
+    <A HREF="#processes">Tuning Child Processes</A> 
+    <LI>
+    <A HREF="#general">General Tuning</A> 
+    <LI>
+    <A HREF="#example">Example</A> 
+    <LI>
+    <A HREF="#seealso">See Also</A> 
+</UL>
+<H2>
+<A NAME="introduction">Introduction</A></H2>
+<P>
+The <A HREF="http://reality.sgi.com/mja/apache/index.html">patches</A>
+ I contributed to the Apache Project modify Apache's source code and 
+standard configuration files to speed up the processing of HTTP 
+requests in various ways. Still, Apache must be configured, compiled, 
+and tuned to achieve the best performance on a given system. The 
+following sections describe the configurable options relevant for high 
+performance.</P>
+<P>
+The options fall into three categories: those that control the QSC, 
+those that control Apache's child processes, and those that control 
+other things.</P>
+<H2>
+<A NAME="qsc">Tuning the QSC</A></H2>
+<P>
+The <A HREF="../qsc.html">Quick Shortcut Cache (QSC)</A> cuts out 
+unnecessary processing for requests to cached static content. It sports 
+a number of <A HREF="../qsc.html#advanced">configurable options</A>. 
+Two of these, <CODE>QSC_HASH_SIZE</CODE> and <CODE>QSC_MAX_SIZE</CODE>, 
+limit the maximum size of the cache and almost certainly need to be 
+increased from their default values to provide the maximum benefit for 
+a given system. A third, <CODE>QSC_HEADER_GRAIN</CODE> (which normally 
+uses the same value as <CODE>CACHE_ALIGNMENT</CODE>), regulates 
+alignment and padding and can improve performance more than you might 
+think when set correctly. See the <A HREF="../qsc.html">QSC 
+documentation</A> for details on <A HREF="../qsc.html#limit">these 
+options</A> and for instructions on <A HREF="../qsc.html#using">using 
+the QSC</A>.</P>
+<P>
+Also, the QSC can manage the very large amounts of data enabled by a <A
+ HREF="../64-bit.html">64-bit address space</A> although with a slight 
+performance penalty.</P>
+<P>
+As patched, Apache's standard run-time configuration file <CODE>httpd.conf</CODE>
+ enables the QSC when the mmap_static module is installed. Leave the <CODE>QSC 
+on</CODE> directive as is.</P>
+<P>
+Summary of options in this section:</P>
+<UL>
+    <LI>
+    <CODE>configure</CODE> options: 
+    <UL>
+        <LI>
+        <A HREF="../qsc.html#using"><CODE>--enable-module=mmap_static</CODE></A>
+         
+    </UL>
+    <LI>
+    Compilation options: 
+    <UL>
+        <LI>
+        <A HREF="../qsc.html#limit"><CODE>-DQSC_HASH_SIZE=</CODE><EM>something</EM></A>
+         
+        <LI>
+        <A HREF="../qsc.html#limit"><CODE>-DQSC_MAX_SIZE=</CODE><EM>something</EM></A>
+         
+        <LI>
+        <CODE>-DCACHE_ALIGNMENT=</CODE><EM>something</EM> or <CODE>-DQSC_HEADER_GRAIN=</CODE><EM>something</EM>
+         
+        <LI>
+        <A HREF="../64-bit.html">compile for a 64-bit virtual address 
+        space</A> 
+    </UL>
+    <LI>
+    Run-time configuration options: 
+    <UL>
+        <LI>
+        <A HREF="../qsc.html#using"><CODE>mmapfile</CODE> <EM>filename</EM></A>
+         - one for each file 
+        <LI>
+        <A HREF="../qsc.html#using"><CODE>QSC on</CODE></A> 
+    </UL>
+</UL>
+<H2>
+<A NAME="processes">Tuning Child Processes</A></H2>
+<P>
+Under heavy load, a system can spend most of its computing power 
+creating, destroying, and scheduling <A HREF="../process-model.html">Apache 
+child processes</A>. Eliminating all this overhead allows the system to 
+spend more of its time processing HTTP requests but reduces Apache's 
+ability to adapt to a changing load.</P>
+<P>
+As patched, Apache's standard run-time configuration file <CODE>httpd.conf</CODE>
+ removes the limit on the number of requests each child process handles 
+before terminating itself and forcing the parent Apache process to fork 
+a replacement. Leave the <A HREF="../mod/core.html#maxrequestsperchild"><CODE>MaxRequestsPerChild</CODE></A><CODE>
+ 0</CODE> directive as is.</P>
+<P>
+Choose a number of processes and force Apache always to use that 
+number, never more or less. Set the <A
+ HREF="../mod/core.html#minspareservers"><CODE>MinSpareServers</CODE></A>, <A
+ HREF="../mod/core.html#maxspareservers"><CODE>MaxSpareServers</CODE></A>, <A
+ HREF="../mod/core.html#startservers"><CODE>StartServers</CODE></A>, 
+and <A HREF="../mod/core.html#maxclients"><CODE>MaxClients</CODE></A>
+ options all to the same value and ignore the resulting warning:</P>
+<BLOCKQUOTE>
+<CODE>server reached MaxClients setting, consider raising the 
+MaxClients setting</CODE></BLOCKQUOTE>
+<P>
+The number you use is up to you but remember, sometimes having fewer 
+processes runs faster than having more. Start with, say, two per 
+network interface and increase from there as necessary.</P>
+<P>
+Bind interrupts from network interface devices to specific processors 
+(distributing them as evenly as possible across all the processors) and 
+bind the Apache child processes listening to those interfaces to the 
+same processors using the <A HREF="../mod/core.html#listen"><CODE>Listen</CODE></A>
+ directive. Force each child process to listen only to its designated 
+interface -- and eliminate performance-sapping <A
+ HREF="perf-tuning.html#acceptserialization">accept serialization</A>
+ -- by turning <A HREF="../mod/core.html#singlelisten"><CODE>SingleListen</CODE></A><CODE>
+ on</CODE>.</P>
+<P>
+Summary of options in this section:</P>
+<UL>
+    <LI>
+    <CODE>configure</CODE> options: 
+    <UL>
+        <LI>
+        none 
+    </UL>
+    <LI>
+    Compilation options: 
+    <UL>
+        <LI>
+        none 
+    </UL>
+    <LI>
+    Run-time configuration options: 
+    <UL>
+        <LI>
+        <A HREF="../mod/core.html#maxrequestsperchild"><CODE>MaxRequestsPerChild 
+        0</CODE></A> 
+        <LI>
+        <A HREF="../mod/core.html#minspareservers"><CODE>MinSpareServers </CODE><EM>something</EM></A>
+         
+        <LI>
+        <A HREF="../mod/core.html#maxspareservers"><CODE>MaxSpareServers </CODE><EM>same 
+        something as MinSpareServers</EM></A> 
+        <LI>
+        <A HREF="../mod/core.html#startservers"><CODE>StartServers </CODE><EM>same 
+        something as MinSpareServers</EM></A> 
+        <LI>
+        <A HREF="../mod/core.html#maxclients"><CODE>MaxClients </CODE><EM>same 
+        something as MinSpareServers</EM></A> 
+        <LI>
+        <A HREF="../mod/core.html#listen"><CODE>Listen</CODE></A> - 
+        with binding to specific processors 
+        <LI>
+        <A HREF="../mod/core.html#singlelisten"><CODE>SingleListen on</CODE></A>
+         
+    </UL>
+</UL>
+<H2>
+<A NAME="general">General Tuning</A></H2>
+<P>
+Always compile optimized.</P>
+<P>
+Define <CODE>SPEED_DAEMON</CODE> which defines all of these other 
+tokens:</P>
+<UL>
+    <LI>
+    <CODE>USE_QSC</CODE> - enables the <A HREF="#qsc">QSC</A> 
+    <LI>
+    <CODE>FAST_TIME</CODE> - speeds up time-keeping 
+    <LI>
+    <CODE>BUFFERED_LOGS</CODE> - buffers <A
+     HREF="../mod/mod_log_config.html">server log entries</A> 
+    <LI>
+    <CODE>NO_GRACEFUL</CODE> - eliminates signal overhead but disables <A
+     HREF="../stopping.html">graceful restarts</A> 
+    <LI>
+    <CODE>USE_QUICK_LOG</CODE> - accelerates <A
+     HREF="../mod/mod_log_config.html">logging</A> in common-log format 
+</UL>
+<P>
+Define the value of <A HREF="../mod/mod_log_config.html"><CODE>LOG_BUFSIZE</CODE></A>
+ to be some multiple of the system's page size, less a few dozen bytes 
+or so for overhead.</P>
+<P>
+Use only the <A HREF="../mod/mod_log_config.html">Common Log Format</A>.</P>
+<P>
+Raise the limit on the number of response bytes written at a time by 
+defining the value of <CODE>MMAP_SEGMENT_SIZE</CODE> to be larger than 
+the largest cached file -- but not on Linux, where this actually slows 
+things down!</P>
+<P>
+Make the listen queue size as large as possible using the <A
+ HREF="../mod/core.html#listenbacklog"><CODE>ListenBacklog</CODE></A>
+ directive.</P>
+<P>
+Summary of options in this section:</P>
+<UL>
+    <LI>
+    <CODE>configure</CODE> options: 
+    <UL>
+        <LI>
+        none 
+    </UL>
+    <LI>
+    Compilation options: 
+    <UL>
+        <LI>
+        <CODE>-O</CODE> 
+        <LI>
+        <CODE>-DSPEED_DAEMON</CODE> 
+        <LI>
+        <A HREF="../mod/mod_log_config.html"><CODE>-DLOG_BUFSIZE=</CODE><EM>something</EM></A>
+         
+        <LI>
+        <CODE>-DMMAP_SEGMENT_SIZE=</CODE><EM>something</EM> 
+    </UL>
+    <LI>
+    Run-time configuration options: 
+    <UL>
+        <LI>
+        use only the <A HREF="../mod/mod_log_config.html">Common Log 
+        Format</A> 
+        <LI>
+        <A HREF="../mod/core.html#listenbacklog"><CODE>ListenBacklog </CODE><EM>something</EM></A>
+         
+    </UL>
+</UL>
+<H2>
+<A NAME="example">Example</A></H2>
+<P>
+Here is the configuration I use to achieve maximum SPECweb96 
+performance on an SGI Origin200 server running Irix 6.5 with two 
+processors, two gigabytes of memory, and four 100BaseT network 
+interfaces. Without any patching or tuning Apache on this system 
+handles 240 operations per second; with my patches and the following 
+tuning it handles 2400*.</P>
+<BLOCKQUOTE>
+<EM>* These are actual SPECweb96 results and while I believe they are 
+accurate and meaningful, they have not been submitted to SPEC for 
+review or publication. The following is for illustrative purposes only 
+and is not a SPECweb96 disclosure.</EM></BLOCKQUOTE>
+<UL>
+    <LI>
+    <CODE>configure</CODE> options: 
+    <UL>
+        <LI>
+        <CODE>--enable-module=mmap_static</CODE> 
+    </UL>
+    <LI>
+    Compilation options: 
+    <UL>
+        <LI>
+        <CODE>-O2</CODE> 
+        <LI>
+        <CODE>-DSPEED_DAEMON</CODE> 
+        <LI>
+        <CODE>-DLOG_BUFSIZE=65500</CODE> 
+        <LI>
+        <CODE>-DMMAP_SEGMENT_SIZE=1048576</CODE> 
+        <LI>
+        <CODE>-DQSC_HASH_SIZE=32768</CODE> 
+        <LI>
+        <CODE>-DQSC_MAX_SIZE=5000000</CODE> 
+    </UL>
+    <LI>
+    Run-time configuration options: 
+    <PRE>
+ServerType standalone
+ServerName <EM>something</EM>
+ServerAdmin root
+ServerRoot /a/apache
+ServerSignature Off
+PidFile /a/apache/logs/httpd.pid
+ScoreBoardFile /a/apache/logs/httpd.scoreboard
+Timeout 300
+KeepAlive On
+MaxKeepAliveRequests 0
+KeepAliveTimeout 15
+MinSpareServers 12
+MaxSpareServers 12
+StartServers 12
+MaxClients 12
+MaxRequestsPerChild 0
+User nobody
+Group nobody
+Port 80
+Listen 100.100.100.101:80 0
+Listen 100.100.100.102:80 0
+Listen 100.100.100.103:80 1
+Listen 100.100.100.104:80 1
+ListenBacklog 1000
+SingleListen on
+QSC on
+
+ClearModuleList
+AddModule mod_mmap_static.c
+AddModule mod_log_config.c
+
+DocumentRoot &quot;/a/htdocs&quot;
+&lt;Directory /&gt;
+    Options FollowSymLinks
+    AllowOverride None
+#   Allow from all
+&lt;/Directory&gt;
+UseCanonicalName Off
+DefaultType text/plain
+HostnameLookups Off
+ErrorLog /b/logs/errors-apache
+LogLevel warn
+LogFormat &quot;%a %l %u %t \&quot;%r\&quot; %&gt;s %b&quot; quick
+CustomLog /b/logs/access-apache quick
+
+AddModule mod_mime.c
+AddModule mod_status.c
+AddModule mod_info.c
+&lt;Location /server-status&gt;
+    SetHandler server-status
+&lt;/Location&gt;
+&lt;Location /server-info&gt;
+    SetHandler server-info
+&lt;/Location&gt;
+
+mmapfile /a/htdocs/spec/file_set/dir0/class0_0
+mmapfile /a/htdocs/spec/file_set/dir0/class0_1
+mmapfile /a/htdocs/spec/file_set/dir0/class0_2
+mmapfile /a/htdocs/spec/file_set/dir0/class0_3
+ <EM>...</EM>
+mmapfile /a/htdocs/spec/file_set/dir223/class3_5
+mmapfile /a/htdocs/spec/file_set/dir223/class3_6
+mmapfile /a/htdocs/spec/file_set/dir223/class3_7
+mmapfile /a/htdocs/spec/file_set/dir223/class3_8
+AddModuleInfo mod_mmap_static.c &quot;Configured for 2500 SPECweb96 ops/sec&quot;
+</PRE>
+</UL>
+<H2>
+<A NAME="seealso">See also</A></H2>
+<UL>
+    <LI>
+    <A HREF="../qsc.html">QSC documentation</A> 
+    <LI>
+    <A HREF="http://reality.sgi.com/mja/apache/index.html">My 
+    speed-demon patches</A> 
+    <LI>
+    <A HREF="http://www.sgi.com/tech/web">SGI's Web Server Tuning Guide</A>
+    <LI>
+    <A HREF="../mod/core.html">Apache core module documentation</A>
+    <LI>
+    <A HREF="../mod/mod_log_config.html">Logging module documentation</A>
+    <LI>
+    <A HREF="perf.html">Other performance tuning documents</A>
+</UL>
+<HR>
+<CENTER><H3 ALIGN="CENTER">
+Apache HTTP Server Version 1.3 </H3>
+</CENTER><P>
+<A HREF="./"><IMG SRC="../images/index.gif" ALT="Index"></A> </P>
+</BODY>
+</HTML>
diff -Naur apache_1.3.6+01-08/htdocs/manual/misc/perf-tuning.html apache_1.3.6+01-09/htdocs/manual/misc/perf-tuning.html
--- apache_1.3.6+01-08/htdocs/manual/misc/perf-tuning.html	Tue Jul 20 22:24:35 1999
+++ apache_1.3.6+01-09/htdocs/manual/misc/perf-tuning.html	Wed Nov  3 10:28:37 1999
@@ -39,6 +39,13 @@
 performance out of Apache's current model, and want to understand why
 it does some things which slow it down.
 
+<P>Mike Abbott from SGI has increased Apache's performance ten-fold for
+static HTTP GET requests such as those issued by the <A
+HREF="http://www.specbench.org/osg/web96/">SPECweb96</A> benchmark.  See
+<A HREF="perf-mja.html">his tuning document</A> and SGI's <A
+HREF="http://www.sgi.com/tech/web">Web Server Performance Tuning
+Guide</A> for more information.
+
 <P>Note that this is tailored towards Apache 1.3 on Unix.  Some of it applies
 to Apache on NT.  Apache on NT has not been tuned for performance yet,
 in fact it probably performs very poorly because NT performance requires
diff -Naur apache_1.3.6+01-08/htdocs/manual/misc/perf.html apache_1.3.6+01-09/htdocs/manual/misc/perf.html
--- apache_1.3.6+01-08/htdocs/manual/misc/perf.html	Mon Mar 22 16:17:45 1999
+++ apache_1.3.6+01-09/htdocs/manual/misc/perf.html	Wed Nov  3 10:28:37 1999
@@ -33,6 +33,7 @@
 <LI><A HREF="#BSD">BSD-based (BSDI, FreeBSD, etc)</A>
 <LI><A HREF="#DEC">Digital UNIX</A>
 <LI><A HREF="perf-hp.html">HPUX</A>
+<LI><A HREF="#IRIX">SGI IRIX</A>
 <LI><A HREF="#Linux">Linux</A>
 <LI><A HREF="#Solaris">Solaris</A>
 <LI><A HREF="#SunOS">SunOS 4.x</A>
@@ -73,6 +74,15 @@
   <LI>We have some <A HREF="perf-dec.html">newsgroup postings</A> on how
       to tune Digital UNIX 3.2 and 4.0.
 </UL>
+
+<P><HR>
+<H3><A NAME="IRIX">
+IRIX
+</A></H3>
+
+See <A HREF="perf-mja.html">Mike Abbott's performance tuning
+document</A> and SGI's <A HREF="http://www.sgi.com/tech/web">Web Server
+Performance Tuning Guide</A>.
 
 <P><HR>
 
diff -Naur apache_1.3.6+01-08/htdocs/manual/mod/mod_mmap_static.html apache_1.3.6+01-09/htdocs/manual/mod/mod_mmap_static.html
--- apache_1.3.6+01-08/htdocs/manual/mod/mod_mmap_static.html	Thu Sep  2 11:40:28 1999
+++ apache_1.3.6+01-09/htdocs/manual/mod/mod_mmap_static.html	Wed Oct 20 16:41:09 1999
@@ -64,6 +64,10 @@
   is that this check would need an extra <CODE>stat()</CODE> every time which
   is a waste and against the intent of I/O reduction.
   </P>
+  <P>
+  Note that mapping a large number of files greatly increases server
+  start-up and restart time.
+  </P>
 
   <H2>Directives</H2>
   <UL>
diff -Naur apache_1.3.6+01-08/htdocs/sgi_performance.gif.uu apache_1.3.6+01-09/htdocs/sgi_performance.gif.uu
--- apache_1.3.6+01-08/htdocs/sgi_performance.gif.uu
+++ apache_1.3.6+01-09/htdocs/sgi_performance.gif.uu	Wed Nov  3 13:36:08 1999
@@ -0,0 +1,46 @@
+begin 444 sgi_performance.gif
+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
+K<(=+W.(:][C(3:YRE\O<YCKWN="-KG2G2]WJ6O>Z"MC-KG:WRUT1A```.PVN
+`
+end
diff -Naur apache_1.3.6+01-08/src/main/http_main.c apache_1.3.6+01-09/src/main/http_main.c
--- apache_1.3.6+01-08/src/main/http_main.c	Thu Sep  2 10:18:50 1999
+++ apache_1.3.6+01-09/src/main/http_main.c	Wed Oct 20 16:42:16 1999
@@ -985,7 +985,7 @@
     fprintf(stderr, "Usage: %s [-d directory] [-f file]\n", bin);
 #endif
     fprintf(stderr, "       %s [-C \"directive\"] [-c \"directive\"]\n", pad);
-    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t]\n", pad);
+    fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-i]\n", pad);
     fprintf(stderr, "Options:\n");
 #ifdef SHARED_CORE
     fprintf(stderr, "  -R directory     : specify an alternate location for shared object files\n");
@@ -1006,6 +1006,7 @@
     fprintf(stderr, "  -k shutdown      : tell running Apache to shutdown\n");
     fprintf(stderr, "  -k restart       : tell running Apache to do a graceful restart\n");
 #endif
+    fprintf(stderr, "  -i               : do not daemonize\n");
     exit(1);
 }
 
@@ -2933,6 +2934,8 @@
  * Here follows a long bunch of generic server bookkeeping stuff...
  */
 
+int daemonize = 1;
+
 static void detach(void)
 {
 #if !defined(WIN32)
@@ -2942,12 +2945,14 @@
 #if !defined(MPE) && !defined(OS2) && !defined(TPF)
 /* Don't detach for MPE because child processes can't survive the death of
    the parent. */
-    if ((x = fork()) > 0)
-	exit(0);
-    else if (x == -1) {
-	perror("fork");
-	fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
-	exit(1);
+    if (daemonize) {
+	if ((x = fork()) > 0)
+	    exit(0);
+	else if (x == -1) {
+	    perror("fork");
+	    fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
+	    exit(1);
+	}
     }
     RAISE_SIGSTOP(DETACH);
 #endif
@@ -2977,24 +2982,26 @@
     }
 #endif
 
-    /* close out the standard file descriptors */
-    if (freopen("/dev/null", "r", stdin) == NULL) {
-	fprintf(stderr, "%s: unable to replace stdin with /dev/null: %s\n",
-		ap_server_argv0, strerror(errno));
-	/* continue anyhow -- note we can't close out descriptor 0 because we
-	 * have nothing to replace it with, and if we didn't have a descriptor
-	 * 0 the next file would be created with that value ... leading to
-	 * havoc.
+    if (daemonize) {
+	/* close out the standard file descriptors */
+	if (freopen("/dev/null", "r", stdin) == NULL) {
+	    fprintf(stderr, "%s: unable to replace stdin with /dev/null: %s\n",
+		    ap_server_argv0, strerror(errno));
+	    /* continue anyhow -- note we can't close out descriptor 0 because we
+	     * have nothing to replace it with, and if we didn't have a descriptor
+	     * 0 the next file would be created with that value ... leading to
+	     * havoc.
+	     */
+	}
+	if (freopen("/dev/null", "w", stdout) == NULL) {
+	    fprintf(stderr, "%s: unable to replace stdout with /dev/null: %s\n",
+		    ap_server_argv0, strerror(errno));
+	}
+	/* stderr is a tricky one, we really want it to be the error_log,
+	 * but we haven't opened that yet.  So leave it alone for now and it'll
+	 * be reopened moments later.
 	 */
     }
-    if (freopen("/dev/null", "w", stdout) == NULL) {
-	fprintf(stderr, "%s: unable to replace stdout with /dev/null: %s\n",
-		ap_server_argv0, strerror(errno));
-    }
-    /* stderr is a tricky one, we really want it to be the error_log,
-     * but we haven't opened that yet.  So leave it alone for now and it'll
-     * be reopened moments later.
-     */
 #endif /* ndef WIN32 */
 }
 
@@ -4713,7 +4720,7 @@
 
 #ifndef TPF
     while ((c = getopt(argc, argv,
-				    "D:C:c:Xd:f:vVlLR:Sth"
+				    "D:C:c:Xd:f:vVlLR:Sthi"
 #ifdef DEBUG_SIGSTOP
 				    "Z:"
 #endif
@@ -4742,6 +4749,7 @@
 	    ap_set_version();
 	    printf("Server version: %s\n", ap_get_server_version());
 	    printf("Server built:   %s\n", ap_get_server_built());
+	    printf("Performance Tuned by SGI <http://www.sgi.com>\n");
 	    exit(0);
 	case 'V':
 	    ap_set_version();
@@ -4778,6 +4786,9 @@
 	    break;
 	case 'h':
 	    usage(argv[0]);
+	case 'i':
+	    daemonize = 0;
+	    break;
 	case '?':
 	    usage(argv[0]);
 	}
diff -Naur apache_1.3.6+01-08/src/modules/experimental/mod_mmap_static.c apache_1.3.6+01-09/src/modules/experimental/mod_mmap_static.c
--- apache_1.3.6+01-08/src/modules/experimental/mod_mmap_static.c	Thu Sep  2 10:37:38 1999
+++ apache_1.3.6+01-09/src/modules/experimental/mod_mmap_static.c	Wed Oct 20 16:51:19 1999
@@ -129,6 +129,7 @@
     void *mm;
     struct stat finfo;
     char mtimestr[32];
+    char sizestr[21];	/* big enough to hold any 64-bit file size + null */
 } a_file;
 
 typedef struct {
@@ -208,6 +209,7 @@
     tmp.filename = ap_pstrdup(cmd->pool, filename);
     ap_gm_timestr_822_buf(tmp.mtimestr, sizeof tmp.mtimestr,
 	tmp.finfo.st_mtime);
+    ap_snprintf(tmp.sizestr, sizeof tmp.sizestr, "%ld", (long) tmp.finfo.st_size);
     sconf = ap_get_module_config(cmd->server->module_config, &mmap_static_module);
     new_file = ap_push_array(sconf->files);
     *new_file = tmp;
@@ -368,10 +370,18 @@
     }
 
     ap_set_etag(r);
-    if (((errstatus = ap_meets_conditions(r)) != OK)
-	|| (errstatus = ap_set_content_length (r, (ap_int32) match->finfo.st_size))) {
-	    return errstatus;
-    }
+
+    if ((errstatus = ap_meets_conditions(r)) != OK)
+	return errstatus;
+
+    /*
+     * ap_set_content_length() always converts the same number and never
+     * returns an error.  Accelerate it.
+     *	if ((errstatus = ap_set_content_length (r, (ap_int32) match->finfo.st_size)))
+     *	    return errstatus;
+     */
+    r->clength = (ap_int32) match->finfo.st_size;
+    ap_table_setn(r->headers_out, "Content-Length", match->sizestr);
 
     rangestatus = ap_set_byterange(r);
 

Re: [PATCH] 10x performance increase patch #9

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Ed Korthof wrote:
> 
> also, setting MaxRequestsPerChild to 0 in the default distributed conf
> file is probably not so ideal ... since it does cause problems in some
> situations (dep on os and -- more often -- third party code).

Setting it to zero (unlimited) is an excellent idea IFF you
have confidence that there are no resource leaks.  Since we're
talking performance here, set it to zero in a particular platform,
start the server, measure the resource consumption, pump a few
requests through it, measure again, and then pump 1*10E6 requests
through it and measure again.  If the last two measurements are
essentially equal, I'd say you're safe in sticking with the
unlimited value.

3P libraries and modules are just as villainous as system ones
when it comes to having insidious leaks.
-- 
#ken    P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://ASFD.MeepZor.Com/>

Re: [PATCH] 10x performance increase patch #9

Posted by Ed Korthof <ed...@apache.org>.
hi --

i've one question: i'm not clear on how the -i option is preferable to the
existing -X option, which is what i've always used for debugging.  is this
just a matter of documentation?  documentation of -X appears to be sparse.

(of course, -i now appears to be used for apache on win32: for installing
as a service.  so either way, at the least a new name would be required.)

also, setting MaxRequestsPerChild to 0 in the default distributed conf
file is probably not so ideal ... since it does cause problems in some
situations (dep on os and -- more often -- third party code).

thanks --

ed