httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject Re: ack re: [PATCH] performance improvement
Date Sun, 02 Feb 1997 04:54:04 GMT
On Sat, 1 Feb 1997, Ed Korthof wrote:

> I'm not too surprised about the minimal improvements from changing the
> tests.  Really, we need a better method to parse the file...
> 
> I don't know the frequency with which GET_CHAR is used in different
> sections, but find_string does seem to be the most likely resource hog.
> 
> Could you send your whole patch?  Ugly doesn't bother me too much, since
> I'd expect primary development to shift from this code base to something
> new (for Apache 2.0) once we finish 1.2.  Besides, what's there now is
> pretty ugly & somewhat inefficient...

I modified the way I did it slightly since my first experiment.  

With no includes:
        1.75 real         0.03 user         0.62 sys

With includes as the current tree has:
        7.62 real         0.02 user         0.50 sys

With includes after this patch:
        4.21 real         0.01 user         0.50 sys

These numbers are on a 
	echo "GET /~marcs/i3.html" | time nc -n -vv 127.0.0.1 80 > /dev/null

Where i3.html is ~4 megs long and contains only one SSI directive at the
start, with the rest being plain text.  My test methods aren't overly
accurate, but they do demonstrate the general trend.  I think something
similar to the below (but cleaned up a bit) may be worthwhile adding.

Index: mod_include.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_include.c,v
retrieving revision 1.21
diff -c -r1.21 mod_include.c
*** mod_include.c	1997/01/20 04:28:13	1.21
--- mod_include.c	1997/02/02 04:42:01
***************
*** 113,122 ****
--- 113,136 ----
      }
  }
  
+ 
+ #define PUT_CH(x) \
+  { \
+    outbuf[outind++] = x; \
+    if (outind == 5000) { rwrite(outbuf, 5000, r); outind = 0; } \
+  }
+ 
+ #define FLUSH_CH() \
+  { \
+    rwrite(outbuf, outind, r); \
+    outind = 0; \
+  }
+ 
  #define GET_CHAR(f,c,r,p) \
   { \
     int i = getc(f); \
     if(feof(f) || ferror(f) || (i == -1)) { \
+ 	FLUSH_CH(); \
          pfclose(p,f); \
          return r; \
     } \
***************
*** 129,156 ****
   * matter much, but this is an inner loop...
   */
  
  int find_string(FILE *in,char *str, request_rec *r, int printing) {
      int x,l=strlen(str),p;
      char c;
  
      p=0;
      while(1) {
          GET_CHAR(in,c,1,r->pool);
          if(c == str[p]) {
!             if((++p) == l)
                  return 0;
          }
          else {
              if (printing) {
                  for(x=0;x<p;x++) {
!                     rputc(str[x],r);
                  }
!                 rputc(c,r);
              }
              p=0;
          }
      }
  }
  
  /*
   * decodes a string containing html entities or numeric character references.
--- 143,178 ----
   * matter much, but this is an inner loop...
   */
  
+    
  int find_string(FILE *in,char *str, request_rec *r, int printing) {
      int x,l=strlen(str),p;
      char c;
+     char outbuf[5000];
+     int outind = 0;
  
      p=0;
      while(1) {
          GET_CHAR(in,c,1,r->pool);
          if(c == str[p]) {
!             if((++p) == l) {
! 		FLUSH_CH();
                  return 0;
+ 	    }
          }
          else {
              if (printing) {
                  for(x=0;x<p;x++) {
! 		    PUT_CH(str[x]);
                  }
!                 PUT_CH(c);
              }
              p=0;
          }
      }
  }
+ 
+ #undef FLUSH_CH
+ #define FLUSH_CH()
  
  /*
   * decodes a string containing html entities or numeric character references.


Mime
View raw message