Received: by taz.hyperreal.com (8.8.4/V2.0) id TAA27362; Sat, 15 Feb 1997 19:34:52 -0800 (PST) Received: from twinlark.arctic.org by taz.hyperreal.com (8.8.4/V2.0) with SMTP id TAA27351; Sat, 15 Feb 1997 19:34:49 -0800 (PST) Received: (qmail 21987 invoked by uid 500); 16 Feb 1997 03:34:59 -0000 Date: Sat, 15 Feb 1997 19:34:59 -0800 (PST) From: Dean Gaudet To: new-httpd@hyperreal.com Subject: Re: [PATCH] my version of the mod_include outbut buffering (fwd) In-Reply-To: <199702160329.WAA07258@shado.jaguNET.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com I actually did a bunch of the work implementing the boyer-moore-horspool stuff so that we could speed this up even more... but that's definately a feature and not for 1.2. I'm running Marc's patch on one of my servers, so I give it a +1... but I respect Rob's sentiment that this is a feature. Dean On Sat, 15 Feb 1997, Jim Jagielski wrote: > +1... > > It would be interesting to see if it still improves things, > performance-wise, when using a larger SNDBUF size for the > socket. Either way, it's win-win! > > Marc Slemko wrote: > > > > Repost. On a large file with no SSIs but still being parsed by > > mod_include it sped up output by two to three times on my FreeBSD system. > > > > 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/08 02:49:56 > > *************** > > *** 113,156 **** > > } > > } > > > > ! #define GET_CHAR(f,c,r,p) \ > > { \ > > int i = getc(f); \ > > ! if(feof(f) || ferror(f) || (i == -1)) { \ > > ! pfclose(p,f); \ > > ! return r; \ > > } \ > > c = (char)i; \ > > } > > > > - /* --------------------------- Parser functions --------------------------- */ > > - > > - /* Grrrr... rputc makes this slow as all-get-out. Elsewhere, it doesn't > > - * 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 > ! rputc(str[x],r); > > } > > ! rputc(c,r); > > } > > p=0; > > } > > } > > } > > > > /* > > * decodes a string containing html entities or numeric character references. > > --- 113,209 ---- > > } > > } > > > > ! > > ! > > ! /* --------------------------- Parser functions --------------------------- */ > > ! > > ! #define OUTBUFSIZE 4096 > > ! /* PUT_CHAR and FLUSH_BUF currently only work within the scope of > > ! * find_string(); they are hacks to avoid calling rputc for each and > > ! * every character output. A common set of buffering calls for this > > ! * type of output SHOULD be implemented. > > ! */ > > ! #define PUT_CHAR(c,r) \ > > ! { \ > > ! outbuf[outind++] = c; \ > > ! if (outind == OUTBUFSIZE) { FLUSH_BUF(r) }; \ > > ! } > > ! > > ! /* there SHOULD be some error checking on the return value of > > ! * rwrite, however it is unclear what the API for rwrite returning > > ! * errors is and little can really be done to help the error in > > ! * any case. > > ! */ > > ! #define FLUSH_BUF(r) \ > > ! { \ > > ! rwrite(outbuf, outind, r); \ > > ! outind = 0; \ > > ! } > > ! > > ! /* > > ! * f: file handle being read from > > ! * c: character to read into > > ! * ret: return value to use if input fails > > ! * r: current request_rec > > ! * > > ! * This macro is redefined after find_string() for historical reasons > > ! * to avoid too many code changes. This is one of the many things > > ! * that should be fixed. > > ! */ > > ! #define GET_CHAR(f,c,ret,r) \ > > { \ > > int i = getc(f); \ > > ! if(i == EOF) { /* either EOF or error -- needs error handling if latter */ \ > > ! if (ferror(f)) \ > > ! fprintf(stderr, "encountered error in GET_CHAR macro, mod_include.\n"); \ > > ! FLUSH_BUF(r); \ > > ! pfclose(r->pool,f); \ > > ! return ret; \ > > } \ > > c = (char)i; \ > > } > > > > int find_string(FILE *in,char *str, request_rec *r, int printing) { > > int x,l=strlen(str),p; > > + char outbuf[OUTBUFSIZE]; > > + int outind = 0; > > char c; > > > > p=0; > > while(1) { > > ! GET_CHAR(in,c,1,r); > > if(c == str[p]) { > > ! if((++p) == l) { > > ! FLUSH_BUF(r); > > return 0; > > + } > > } > > else { > > if (printing) { > > for(x=0;x > ! PUT_CHAR(str[x],r); > > } > > ! PUT_CHAR(c,r); > > } > > p=0; > > } > > } > > } > > + > > + #undef FLUSH_BUF > > + #undef PUT_CHAR > > + #undef GET_CHAR > > + #define GET_CHAR(f,c,r,p) \ > > + { \ > > + int i = getc(f); \ > > + if(i == EOF) { /* either EOF or error -- needs error handling if latter */ \ > > + if (ferror(f)) \ > > + fprintf(stderr, "encountered error in GET_CHAR macro, mod_include.\n"); \ > > + pfclose(p,f); \ > > + return r; \ > > + } \ > > + c = (char)i; \ > > + } > > > > /* > > * decodes a string containing html entities or numeric character references. > > > > > -- > ==================================================================== > Jim Jagielski | jaguNET Access Services > jim@jaguNET.com | http://www.jaguNET.com/ > "Not the Craw... the CRAW!" >