httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: cvs commit: apache-2.0/src/main http_protocol.c
Date Thu, 09 Nov 2000 03:34:16 GMT
On Wed, Nov 08, 2000 at 07:23:23PM -0800, rbb@covalent.net wrote:
> > > Note that TRANSIENT and IMMORTAL do not need refcounting. The copied bucket
> > > can just refer to the same data.
> > 
> > Transients most definately need to be ref-counted.  If they aren't, then
> > you won't know the ref-count when setting it aside.  If we ref-count, then
> > we can insert the same transient string into the brigade multiple times as
> > multiple instances of the same string, and we will only copy the data
> > once.
> 
> That probably isn't clear at all.  You are correct that currently
> transients don't need to be ref-counted.  However, that limits transient
> data's usability, because a given transient string can only appear in a
> bucket brigade once optimally.  If it occurs twice, then we have two
> buckets (one for each instance), and we copy it twice whenever we set it
> aside.  If we ref-count the transient buckets, then we can insert a
> transient string multiple times in a single brigade, and we will only copy
> it once.

Right :-) ... I was gonna say... :-)

Hrm. This would get a bit tricky. Say you have two TRANSIENT buckets. A and
B. If you setaside A, then it becomes a HEAP bucket. Now... how does B refer
to the HEAP bucket so that it can optimize its setaside operation?

[ note: copy of a transient always produces a transient, no matter what ]

I think the answer is that a transient refers to a (refcounted) substructure
that looks something like:

{
    const char *data;
    apr_size_t length;
    int on_heap;
}

When you first create the transient, on_heap is FALSE and data/length refer
to the transient memory.

copy() just refers to the same substructure.

setaside() of a transient will look in the substructure. If on_heap is FALSE,
then the data is copied to the heap and the "data" pointer is updated and
on_heap is set to TRUE. The bucket is then transformed into a HEAP bucket.
During a setaside(), if on_heap is TRUE, then we just build another HEAP
bucket around it. [ and there is some refcount magic to do ]


So... true: TRANSIENT should be refcounted for optimizing setaside().
IMMORTAL does not need to be refcounted.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Mime
View raw message