You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Niklas Edmundsson <ni...@acc.umu.se> on 2006/10/08 20:02:10 UTC

[PATCH] mod_disk_cache background copy

This patch implements copying a file in the background so the client 
initiating the caching can get the file delivered by 
read-while-caching instead of having to wait for the file to finish.

I'll attach it to bug #39380 as well, with less comments.

The method used here is rather crude, but works well enough in 
practice. It should suffice as a first step of implementing this 
functionality.

Known missing features:
* Documentation for the CacheMinBGSize parameter, the minimum file
   size to to do background caching. Typically set to what your backend
   can deliver in approx 250ms at normal load (given 200ms sleep loop).
* It doesn't set the stacksize for the background thread, it made
   stuff unloadable on AIX which probably means some symbol is missing
   in an export table somewhere.
* Testing of the forked variation. This has only had testing with the
   worker MPM on Unix.

Known areas of possible improvements:
* Figure out why the cleanup-function isn't run before the fd's are
   closed so the private pool can be removed.
* I suppose it's possible to use cross-threads-fd's with some
   setaside-magic instead of open new fd's in the bgcopy thread.
* Experiment with a separate copy-files-thread spawned at
   initialization for threaded environments.
* The forked thingie could probably use a few cleanups.

In practice I don't think those improvements will give much in terms 
of performance but it sure would be more elegant :)

/Nikke
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     nikke@acc.umu.se
---------------------------------------------------------------------------
  "It's funny how the Earth never opens up and swallows you when you want it to."
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Re: [PATCH] mod_disk_cache background copy

Posted by Niklas Edmundsson <ni...@acc.umu.se>.
On Wed, 11 Oct 2006, Graham Leggett wrote:

>> This patch implements copying a file in the background so the client 
>> initiating the caching can get the file delivered by read-while-caching 
>> instead of having to wait for the file to finish.
>
> Something that Joe Orton raised, and that I've been looking into in more 
> detail.
>
> The copy_body function currently only supports file buckets, which 
> specifically excludes buckets generated by say mod_proxy, or mod_cgi. From my 
> testing, for these non file buckets, the response is downloaded and cached 
> fully, then the client gets fed data. Initially I understood this as an 
> optimisation specific to files, assuming that file buckets were the only 
> buckets that could potentially exceed available RAM, but the case where non 
> file buckets are present is currently unhandled.

I don't have enough knowledge of httpd internals to be sure, but 
doesn't the data-generating types insert flush buckets in the stream 
to avoid this? That said, mod_disk_cache seems to be totally unaware 
of flush buckets so I'm either barking up the wrong tree, it's handled 
on a higher level or it isn't handled.

> In theory, the copy body should be able to read from any brigade, rather than 
> just a file brigade, in such a way that it doesn't try and load 4.7GB into 
> RAM at once for file buckets.

The original reason for copy_body() was to have something that could 
be used in a background thread, and the only thing I'm sure can be 
copied in the background is plain files. Everything else must be 
handled the "old" way.

> I am jetlagged right now and can't think straight any more today, will carry 
> on looking at this tomorrow :)

OK. I'll be away for a week or so and might lag quite a bit in 
replying to stuff.

/Nikke
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     nikke@acc.umu.se
---------------------------------------------------------------------------
  Huh?  What?  Am I on-line?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Re: [PATCH] mod_disk_cache background copy

Posted by Graham Leggett <mi...@sharp.fm>.
Niklas Edmundsson wrote:

> This patch implements copying a file in the background so the client 
> initiating the caching can get the file delivered by read-while-caching 
> instead of having to wait for the file to finish.

Something that Joe Orton raised, and that I've been looking into in more 
detail.

The copy_body function currently only supports file buckets, which 
specifically excludes buckets generated by say mod_proxy, or mod_cgi. 
 From my testing, for these non file buckets, the response is downloaded 
and cached fully, then the client gets fed data. Initially I understood 
this as an optimisation specific to files, assuming that file buckets 
were the only buckets that could potentially exceed available RAM, but 
the case where non file buckets are present is currently unhandled.

In theory, the copy body should be able to read from any brigade, rather 
than just a file brigade, in such a way that it doesn't try and load 
4.7GB into RAM at once for file buckets.

I am jetlagged right now and can't think straight any more today, will 
carry on looking at this tomorrow :)

Regards,
Graham
--