Re: Performance analysis questions

Andrew Payne (payne@n8kei.tiac.net)
Fri, 13 May 1994 10:02:34 -0400


George writes:

>>Code like this doesn't help (getline() in util.c):
>>
>> if((ret = read(f,&s[i],1)) <= 0) {
>
>This is done because it wants to hand off the file descriptor to
>CGI scripts that handle POSTs. I'd suggest the right way to fix
>things is to read a bufferful and cat the extra to the scripts that
>need it.

If the common case is GETs (which I suspect it is for most servers), doing
buffered reads and just copying the bytes down to the POST script is
probably the right thing do to. Plus, POST data _tends_ to be short
anyway.

Actually, you can get the best of both methods. Read the first 4 bytes of
the connection. If the method is POST, read the rest of the connection
unbuffered and hand the socket off to the script. Otherwise, do large
block reads and buffer all you'd like. If you seek the ultimate in
performance, the extra code might be worth it.

Make the common case fast,

-andy