You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by jo...@apache.org on 2004/09/29 17:03:59 UTC
cvs commit: httpd-test/perl-framework/c-modules/test_pass_brigade mod_test_pass_brigade.c
jorton 2004/09/29 08:03:59
Modified: perl-framework/c-modules/test_pass_brigade
mod_test_pass_brigade.c
Log:
Prevent death by memory consumption in an --enable-pool-debug/-lefence
build: allocate and {ab,re}use a single brigade structure rather than
allocating one out of r->pool for each block sent (see also "why are
brigades allocated out of pools this is insane" threads).
Revision Changes Path
1.5 +4 -1 httpd-test/perl-framework/c-modules/test_pass_brigade/mod_test_pass_brigade.c
Index: mod_test_pass_brigade.c
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/c-modules/test_pass_brigade/mod_test_pass_brigade.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -d -w -u -r1.4 -r1.5
--- mod_test_pass_brigade.c 15 Jun 2004 15:50:53 -0000 1.4
+++ mod_test_pass_brigade.c 29 Sep 2004 15:03:59 -0000 1.5
@@ -27,6 +27,7 @@
size_t total=0, remaining=1;
char *buff;
size_t buff_size = 8192;
+ apr_bucket_brigade *bb;
if (strcmp(r->handler, "test_pass_brigade")) {
return DECLINED;
@@ -43,15 +44,16 @@
buff = malloc(buff_size);
memset(buff, 'a', buff_size);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
while (total < remaining) {
int left = (remaining - total);
int len = left <= buff_size ? left : buff_size;
- apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
apr_bucket *bucket = apr_bucket_heap_create(buff, len, NULL,
c->bucket_alloc);
apr_status_t status;
+ apr_brigade_cleanup(bb);
APR_BRIGADE_INSERT_TAIL(bb, bucket);
status = ap_pass_brigade(r->output_filters->next, bb);
@@ -71,6 +73,7 @@
len, len);
}
+ apr_brigade_destroy(bb);
fprintf(stderr,
"[mod_test_pass_brigade] done writing %ld of %ld bytes\n",
total, remaining);
Re: cvs commit: httpd-test/perl-framework/c-modules/test_pass_brigade mod_test_pass_brigade.c
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Sep 29, 2004 at 01:19:24PM -0400, Cliff Woolley wrote:
> On Wed, 29 Sep 2004 jorton@apache.org wrote:
>
> > jorton 2004/09/29 08:03:59
> >
> > Modified: perl-framework/c-modules/test_pass_brigade
> > mod_test_pass_brigade.c
> > Log:
> > Prevent death by memory consumption in an --enable-pool-debug/-lefence
> > build: allocate and {ab,re}use a single brigade structure rather than
> > allocating one out of r->pool for each block sent (see also "why are
> > brigades allocated out of pools this is insane" threads).
>
> Um, I actually never saw any such threads. Where were they?
OK, I paraphrased somewhat, but:
recent: http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=108732600304014&w=2
historic: http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=104039770718467&w=2
> Anyway, there actually was a brief period of time about two years ago when
> they were not allocated out of pools. I was under the mistaken impression
> that that was still the case, but apparently brianp reverted his own
> commit about a week afterward for some reason I can no longer recall
> (presumably it broke something and it was easier at the time to revert
> than fix because a new release of httpd was pending).
The fact is that now, we can't fix it in 2.0 because there are output
filters which presume they can apr_brigade_destroy() the brigade passed
in, and there are other filters which presume they can reuse a brigade
which they passed down.
Many of the filters in httpd will allocate new brigades when you pass a
FLUSH bucket up (e.g. PR23567, a slow-running CGI), which leads to
memory usage proportional to number of FLUSH buckets sent etc etc...
joe
Re: cvs commit: httpd-test/perl-framework/c-modules/test_pass_brigade
mod_test_pass_brigade.c
Posted by Cliff Woolley <jw...@virginia.edu>.
On Wed, 29 Sep 2004 jorton@apache.org wrote:
> jorton 2004/09/29 08:03:59
>
> Modified: perl-framework/c-modules/test_pass_brigade
> mod_test_pass_brigade.c
> Log:
> Prevent death by memory consumption in an --enable-pool-debug/-lefence
> build: allocate and {ab,re}use a single brigade structure rather than
> allocating one out of r->pool for each block sent (see also "why are
> brigades allocated out of pools this is insane" threads).
Um, I actually never saw any such threads. Where were they?
Anyway, there actually was a brief period of time about two years ago when
they were not allocated out of pools. I was under the mistaken impression
that that was still the case, but apparently brianp reverted his own
commit about a week afterward for some reason I can no longer recall
(presumably it broke something and it was easier at the time to revert
than fix because a new release of httpd was pending).
Brian, do you remember what the deal was there?
--Cliff