apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject Re: [PATCH] allocate properly-sized buffer for header
Date Thu, 25 Jan 2001 20:25:23 GMT

> > The problem is that it is impossible to do a lot of small writes to a
> > brigade efficiently.  Take as an example, code that needs to add 20 five
> > byte buffers to brigade.  There are two options:
> > 
> > 1)  bigbuff = apr_pstrcat(p, buf1, buf2, buf3, buf4, buf5, ...);
> >     b = apr_bucket_make_pool(p, bigbuff);
> >     APR_INSERT_BRIGADE_TAIL(bb, b);
> > 
> > 2)  b = apr_bucket_make_heap(buf1);
> >     APR_INSERT_BRIGADE_TAIL(bb, b);
> >     b = apr_bucket_make_heap(buf2);
> >     APR_INSERT_BRIGADE_TAIL(bb, b);
> >     b = apr_bucket_make_heap(buf3);
> >     APR_INSERT_BRIGADE_TAIL(bb, b);
> >     ...
> 
> Why write to the brigade instead of the top filter?

Because we aren't always writing to the top filter.  Sometimes, we are
writing to a lower filter.  This is the problem with current
implementation.

> The problem with this type of optimization is that the brigade code
> cannot know the optimal size of a bucket -- only the next
> filter in the chain can know, since what is optimal will depend
> on what kind of processing is done next.

However, the programmer knows what kind of data they are dealing with.  If
it is bufferable, then it should be written to the brigade using a
buffering API.  Otherwise, it should be written using a direct bucket API,
IMO.

> 
> I think that if we are suffering from wasted cycles and pallocs
> due to premature brigade formations, then we should try it the other
> way -- always allocate the bucket structure off the stack, use a
> simple next pointer to connect brigades, and force the filter that
> needs to setaside the data to do so in a way that coalesces the
> bucket data.  That was the main difference between the design we
> are using now and the one Greg proposed prior to the filters meeting.

However, we don't always want to coalesce bucket data.  I am picturing
this case.

file bucket 9k -> 10 byte pool bucket -> 10 byte pool bucket.

We want to coalesce the 2 10 byte buckets, but we don't want to coalesce
the file bucket.  If the buckets are allocated off the stack, how do you
keep the file bucket around?

I have tried to allocate the brigades off the stack, but we rely on the
cleanups to ensure that buckets are freed properly.

I guess I don't see what you are thinking.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Mime
View raw message