Greg Stark wrote:
> 
> Ed Loehr <[EMAIL PROTECTED]> writes:
> 
> > > [EMAIL PROTECTED] (Ed Loehr) wrote:
> > > >Any ideas on why would this output statement takes 15-20 seconds to
> > > >send a 120kb page to a browser on the same host?
> > > >
> > > >    $| = 1;  # Don't buffer anything...send it asap...
> > > >    $r->print( $data );
> 
> You don't say how many lines your 120kb of data is. If it's about 40
> characters per line average that's 30k calls to write (because you turned
> buffering off). Calls to write ought to be around 100us but if they were slow
> for some reason and took 500us then that would explain the 15s.

A number of the lines are 5-6K each.  Context is a rather large
html-based spreadsheet-like page.

> Additionally you're probably filling the kernel buffer and forcing a context
> switch several times. If the buffer is about 4k then there would be 3k context
> switches each about 10ms on linux, or about 30s of latency. There was a debate
> over the usefulness of the ProxyReceiveBuffer parameter, and even that isn't
> the same as this buffer, but it ought to be possible for Apache to setsockopt
> to ask for a larger buffer.
> 
> In short, don't set $|=1, it will only slow down this process, and investigate
> if there's any way to increase the size of the kernel buffer for the socket in
> Apache. Lots of people would be interested to know if you turn up anything
> there.

With buffering on or off, and max "segment" size of 900 bytes in any
one call to print() (or $r->print()), but doing 120kb worth of
printing in rapid succession, the smaller-but-still-large delay shows
up typically around 100kb into it.  The only way I was able to make
the large delays disappear so far is to sleep 1 every 50 prints or
so...but that's not really disappearing, now is it...

Experimentally, it appears this is simply too much data too quickly. 
I think I've seen $|=1 make a big difference with other non-local
NT/MSIE clients, even on these 120kb pages.  I've consistently been
able to reproduce this problem in both buffered and non-buffered mode
with linux netscape 4.7, both locally and remotely.

I'll look into the kernel buffer issue... :(

Cheers,
Ed Loehr

Reply via email to