Re: Small optimization patch for 1.3

2003-03-30 Thread Justin Erenkrantz
--On Friday, March 28, 2003 10:30 AM -0800 Rasmus Lerdorf <[EMAIL PROTECTED]> 
wrote:

In doing a bit of performance tweaking on 1.3, I noticed that
ap_send_header_field() does an ap_rvputs() with each little piece of a
header which results in separate ap_bwrite() calls for "Primitive", ":",
"Value", "crlf" for each header line sent.  Rather than having these 1 and
2 character ap_bwrite() calls wouldn't it make more sense to ap_pstrcat()
these little bits together and do a single ap_bputs()?
I don't think it will necessarily effect things because not every ap_bwrite 
call results in a network write.  It should try to fill up the buffer, then 
write only when the buffer is filled or a flush is called.

So, I think the savings of not having these extra calls to ap_bwrite (which 
typically won't block) will be offset by the (very expensive) ap_pstrcat call. 
You'd now be doing two copies (one strcpy and a memcpy).

Not to mention that the lines get longer and harder to read.  -- justin


Small optimization patch for 1.3

2003-03-28 Thread Rasmus Lerdorf
In doing a bit of performance tweaking on 1.3, I noticed that
ap_send_header_field() does an ap_rvputs() with each little piece of a
header which results in separate ap_bwrite() calls for "Primitive", ":",
"Value", "crlf" for each header line sent.  Rather than having these 1 and
2 character ap_bwrite() calls wouldn't it make more sense to ap_pstrcat()  
these little bits together and do a single ap_bputs()?

Trivial patch follows:

Index: http_protocol.c
===
RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
retrieving revision 1.330
diff -u -r1.330 http_protocol.c
--- http_protocol.c 3 Feb 2003 17:13:22 -   1.330
+++ http_protocol.c 28 Mar 2003 18:27:38 -
@@ -1566,7 +1566,7 @@
 return 1;
 }
 }
-return (0 < ap_rvputs(r, fieldname, ": ", fieldval, CRLF, NULL));
+return (0 < ap_bputs(ap_pstrcat(r->pool, fieldname, ": ", fieldval, CRLF, NULL), 
r->connection->client));
 }

 API_EXPORT(void) ap_basic_http_header(request_rec *r)
@@ -1595,7 +1595,7 @@
 #endif /*CHARSET_EBCDIC*/

 /* output the HTTP/1.x Status-Line */
-ap_rvputs(r, protocol, " ", r->status_line, CRLF, NULL);
+ap_bputs(ap_pstrcat(r->pool, protocol, " ", r->status_line, CRLF, NULL), 
r->connection->client);

 /* output the date header */
 ap_send_header_field(r, "Date", ap_gm_timestr_822(r->pool, r->request_time));