httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <>
Subject Re: mod_file_cache performance
Date Tue, 03 Jul 2001 02:33:31 GMT
> On Mon, 2 Jul 2001, Cliff Woolley wrote:
> > On Mon, 2 Jul 2001, dean gaudet wrote:
> >
> > > sendfile() is the best thing to use on linux (and probably everywhere else
> > > that has it).  it doesn't require any virt->phys mappings to be created,
> > > and supports zero-copy.
> >
> > I guess the easy answer is that AP_MIN_BYTES_TO_WRITE ought to be
> > decreased (possibly by a lot).  It's currently set to 8KB.  If it were,
> > say, 1KB, then any file bigger than 1KB would get sendfile'd, even in
> > keepalive requests.  We've been talking about changing it for a while now,
> > and just haven't gotten around to it because no one (that I know of) has
> > done any testing to figure out what a "good" value would be.  How many
> > bytes is "enough" to warrant dumping a packet onto the network?  I don't
> > know for sure, but it's clearly < 8KB.
> you don't need to dump a packet on the network... that's what TCP_CORK is
> all about.  see <> and search for TCP_CORK
> to find out more info.
> the trick to using TCP_CORK is to understand how the haldduplex /
> safe_read stuff worked in 1.3 -- every time you're in need of blocking on
> read (to get more requests) you want to pop the cork.  you want to put a
> new cork on before you write anything

We have safe_read (sort of) in Apache 2.0. When we serve a static file, we open the file,
create a
file_bucket (that contains the open file descriptor) and send the bucket down the filter chain.
sendfile() is used to send the file iff the connection is -not- a keepalive connection.  If
connection is a keepalive connection, the file is mmaped (within min/max size criterion) and
MMAP stored in case we want to pipeline responses back (ie, if the next request is pipelined).

I'm not sure I understand the reason for MMAPing the file, but I'm thinking it had to do with
difficulty of figuring out what to do with multiple file handles should you actually need
to serve
static respoonsese to pipelined requests.  For example, if you have three responses to serve
pipelined, each with three file handles, how do you make all the packets go out optimally
If you MMAP the three files, you cand do a writev() with six vectors (3 sets of headers and
buffers if the files are small), the stack will do the right thing.

On Linux, can you TCP_CORK, call sendfile() x times then do an uncork and have all the packets
out optimally filled? If so, then that is quite cool and that is what we should be doing.
 Am I
correct in assuming that you suggest we not use MMAP at all in a threaded server? That is,
only use
sendfile() or read(file, buf)/write(socket,buf) when using threaded MPMs?


View raw message