You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Davi Arnaut <da...@haxent.com.br> on 2006/10/01 04:32:07 UTC
Re: [PATCH] mod_disk_cache working LFS (filecopy)
On 26/09/2006, at 05:52, Niklas Edmundsson wrote:
>
> This patch depends on "mod_disk_cache LFS-aware config" submitted
> earlier and is for trunk.
>
> It makes caching of large files possible on 32bit machines by:
>
> * Realising that a file is a file and can be copied as such, without
> reading the whole thing into memory first.
Hi,
Wouldn't you avoid a lot of complexity in this patch
if you just deleted from the brigade the implicitly
created heap buckets while reading file buckets ?
Something like:
store_body:
.. if (is_file_bucket(bucket))
copy_file_bucket(bucket, bb);
copy_file_bucket:
while (bucket != sentinel(bb) && is_file_bucket(bucket) {
rv = apr_bucket_read(..)
if (is_heap_bucket(bucket)) {
apr_bucket *tmp = bucket;
bucket = bucket_next(tmp);
bucket_delete(tmp);
}
else
bucket = bucket_next(bucket);
}
IMHO, this is a lot better than all that added complexity
for a corner case.
--
Davi Arnaut
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Davi Arnaut <da...@haxent.com.br>.
Niklas Edmundsson wrote:
> On Mon, 2 Oct 2006, Davi Arnaut wrote:
>
>>> Simpler, yes. But it only has the benefit of not eating all your
>>> memory...
>> Well, that was the goal. Maybe we could merge this one instead and work
>> together on the other goals.
>
> As I have said before, we have a large patchset that fixes a bunch of
> problems. However, since the wish was to merge it in pieces, I have
> started breaking it into pieces for merging.
Thank you.
> If the intent is a total redesign of mod_disk_cache, ie you're not
> interested in these patches at all, please say so and I would have not
> wasted a lot of work on bending our patches to get something that
> works when applying them one by one and then do QA on the thing.
Your work is never wasted, but the overall goal is to achieve a good
code quality whether is comes from you, me or anyone - personally
speaking since I'm not a apache committer.
I'm also interested in the same features you are, but we have to think
about long-term maintainability/quality to avoid half-backed short-term
solutions which wastes everybody's work.
>
>>> * It leaves the brigade containing the uncached entity, so it will
>>> cause the backend to first deliver stuff to be cached and then stuff
>>> to the client.
>> Yeah, that's how mod_disk_cache works. I think it's possible to work
>> around this limitation without using threads by keeping each cache
>> instance with it's own brigades and flushing it occasionally with
>> non-blocking i/o.
>
> The replace_brigade_with_cache()-function simply replaced the brigade
> with an instance pointing to the cached entity.
>
>> Or we could move all disk i/o to a mod_disk_cache exclusive thread pool,
>> it could be configurable at build time whether or not to use a thread pool.
>>
>> Comments ?
>
> I would very happy if people would fix the mod_disk_cache mess so I
> didn't have to. However, since noone seems to have produced something
> usable for our usage in the timeframe mod_disk_cache has existed I was
> forced to hack on it.
>
> I'm trying my best to not give up on having it merged as I know that
> there are other sites interested in it, and now that the first trivial
> bit has been applied I'm hoping that people will at least look at the
> rest... There are bound to be cool apachier ways to solve some of the
> problems, but given that our patch is stable in production and has a
> generally much higher code quality than mod_disk_cache (ever heard of
> error checking/handling?) it would be nice if people at least could
> look at the whole thing before starting to complain at the complexity
> of small parts (or code not touched by the patch, for that matter).
As I said, we should always strive for the best possible quality or we
are doomed to keep fixing it over and over.
>>> * When this evolves to wanting to spawn a thread/process to do the
>>> copying you'll need the "is this a file"-thingie anyway (at least I
>>> need it, but I might have missed some nifty feature in APR).
>> You would just need to copy the remaining buckets (granted if there are
>> no concurrency problems) and send then to a per-process thread pool.
>
> And when not having threads?
non-blocking when possible.
--
Davi Arnaut
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Graham Leggett <mi...@sharp.fm>.
Niklas Edmundsson wrote:
> If the intent is a total redesign of mod_disk_cache, ie you're not
> interested in these patches at all, please say so and I would have not
> wasted a lot of work on bending our patches to get something that works
> when applying them one by one and then do QA on the thing.
At the moment you have a battle tested patch that fixes some very old
issues with cache behaviour that are hangups from the v1.3 days, and
that makes the cache useful in a particularly performance sensitive
environment - the exact kind of environment where mod_cache wants to be
useful.
Although there is haggling over the details of implementation (the cache
as shipped by the ASF needs to be functional across all the platforms
supported, and should perform well on modern platforms), your efforts
are exactly what cache needs right now, which is why I am keen to see
the patches applied as they come in.
Regards,
Graham
--
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Niklas Edmundsson <ni...@acc.umu.se>.
On Mon, 2 Oct 2006, Davi Arnaut wrote:
>> Simpler, yes. But it only has the benefit of not eating all your
>> memory...
>
> Well, that was the goal. Maybe we could merge this one instead and work
> together on the other goals.
As I have said before, we have a large patchset that fixes a bunch of
problems. However, since the wish was to merge it in pieces, I have
started breaking it into pieces for merging.
If the intent is a total redesign of mod_disk_cache, ie you're not
interested in these patches at all, please say so and I would have not
wasted a lot of work on bending our patches to get something that
works when applying them one by one and then do QA on the thing.
>> * It leaves the brigade containing the uncached entity, so it will
>> cause the backend to first deliver stuff to be cached and then stuff
>> to the client.
>
> Yeah, that's how mod_disk_cache works. I think it's possible to work
> around this limitation without using threads by keeping each cache
> instance with it's own brigades and flushing it occasionally with
> non-blocking i/o.
The replace_brigade_with_cache()-function simply replaced the brigade
with an instance pointing to the cached entity.
> Or we could move all disk i/o to a mod_disk_cache exclusive thread pool,
> it could be configurable at build time whether or not to use a thread pool.
>
> Comments ?
I would very happy if people would fix the mod_disk_cache mess so I
didn't have to. However, since noone seems to have produced something
usable for our usage in the timeframe mod_disk_cache has existed I was
forced to hack on it.
I'm trying my best to not give up on having it merged as I know that
there are other sites interested in it, and now that the first trivial
bit has been applied I'm hoping that people will at least look at the
rest... There are bound to be cool apachier ways to solve some of the
problems, but given that our patch is stable in production and has a
generally much higher code quality than mod_disk_cache (ever heard of
error checking/handling?) it would be nice if people at least could
look at the whole thing before starting to complain at the complexity
of small parts (or code not touched by the patch, for that matter).
>> * When this evolves to wanting to spawn a thread/process to do the
>> copying you'll need the "is this a file"-thingie anyway (at least I
>> need it, but I might have missed some nifty feature in APR).
>
> You would just need to copy the remaining buckets (granted if there are
> no concurrency problems) and send then to a per-process thread pool.
And when not having threads?
/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | nikke@acc.umu.se
---------------------------------------------------------------------------
To avoid seeing a fool, break your mirror.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Davi Arnaut <da...@haxent.com.br>.
Niklas Edmundsson wrote:
> On Sun, 1 Oct 2006, Davi Arnaut wrote:
>
>>>> store_body:
>>>> .. if (is_file_bucket(bucket))
>>>> copy_file_bucket(bucket, bb);
>>> Probably, but that doesn't allow for creating a thread/process that
>>> does the copying in the background, which is my long term goal.
>>>
>>> Also, simply doing bucket_delete like that means that the file will
>>> never be sent to the client, which is a bad thing IMO ;)
>> Shame on me, but I said "something like".. :)
>>
>> I guess the attached patch does the same (plus mmap, et cetera) and is
>> much simpler. Comments ?
>
> Simpler, yes. But it only has the benefit of not eating all your
> memory...
Well, that was the goal. Maybe we could merge this one instead and work
together on the other goals.
> * It leaves the brigade containing the uncached entity, so it will
> cause the backend to first deliver stuff to be cached and then stuff
> to the client.
Yeah, that's how mod_disk_cache works. I think it's possible to work
around this limitation without using threads by keeping each cache
instance with it's own brigades and flushing it occasionally with
non-blocking i/o.
Or we could move all disk i/o to a mod_disk_cache exclusive thread pool,
it could be configurable at build time whether or not to use a thread pool.
Comments ?
> * When this evolves to wanting to spawn a thread/process to do the
> copying you'll need the "is this a file"-thingie anyway (at least I
> need it, but I might have missed some nifty feature in APR).
You would just need to copy the remaining buckets (granted if there are
no concurrency problems) and send then to a per-process thread pool.
--
Davi Arnaut
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Niklas Edmundsson <ni...@acc.umu.se>.
On Sun, 1 Oct 2006, Davi Arnaut wrote:
>>> store_body:
>>> .. if (is_file_bucket(bucket))
>>> copy_file_bucket(bucket, bb);
>>
>> Probably, but that doesn't allow for creating a thread/process that
>> does the copying in the background, which is my long term goal.
>>
>> Also, simply doing bucket_delete like that means that the file will
>> never be sent to the client, which is a bad thing IMO ;)
>
> Shame on me, but I said "something like".. :)
>
> I guess the attached patch does the same (plus mmap, et cetera) and is
> much simpler. Comments ?
Simpler, yes. But it only has the benefit of not eating all your
memory...
* It leaves the brigade containing the uncached entity, so it will
cause the backend to first deliver stuff to be cached and then stuff
to the client.
* When this evolves to wanting to spawn a thread/process to do the
copying you'll need the "is this a file"-thingie anyway (at least I
need it, but I might have missed some nifty feature in APR).
/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | nikke@acc.umu.se
---------------------------------------------------------------------------
"Oohhh. Jedi Master. Yoda. You seek Yoda."
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Davi Arnaut <da...@haxent.com.br>.
Niklas Edmundsson wrote:
> On Sat, 30 Sep 2006, Davi Arnaut wrote:
>
>> Hi,
>>
>> Wouldn't you avoid a lot of complexity in this patch
>> if you just deleted from the brigade the implicitly
>> created heap buckets while reading file buckets ?
>>
>> Something like:
>>
>> store_body:
>> .. if (is_file_bucket(bucket))
>> copy_file_bucket(bucket, bb);
>
> Probably, but that doesn't allow for creating a thread/process that
> does the copying in the background, which is my long term goal.
>
> Also, simply doing bucket_delete like that means that the file will
> never be sent to the client, which is a bad thing IMO ;)
Shame on me, but I said "something like".. :)
I guess the attached patch does the same (plus mmap, et cetera) and is
much simpler. Comments ?
--
Davi Arnaut
Re: [PATCH] mod_disk_cache working LFS (filecopy)
Posted by Niklas Edmundsson <ni...@acc.umu.se>.
On Sat, 30 Sep 2006, Davi Arnaut wrote:
> Hi,
>
> Wouldn't you avoid a lot of complexity in this patch
> if you just deleted from the brigade the implicitly
> created heap buckets while reading file buckets ?
>
> Something like:
>
> store_body:
> .. if (is_file_bucket(bucket))
> copy_file_bucket(bucket, bb);
Probably, but that doesn't allow for creating a thread/process that
does the copying in the background, which is my long term goal.
Also, simply doing bucket_delete like that means that the file will
never be sent to the client, which is a bad thing IMO ;)
/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | nikke@acc.umu.se
---------------------------------------------------------------------------
Excuse me, is that a toupee or do you have a tribble on your head
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=