Hi list,

in the old PR51699, Stefan Fritsch turned a sequence like:
     APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(...));
into:
     apr_brigade_putstrs(bb, NULL,...);

(http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_include.c?r1=1159896&r2=1159895&pathrev=1159896)


This kind of construction can be found in several places of httpd (and I was wondering if the same kind of transformation could be a win.



My understanding is that:
- apr_brigade_[putc|puts|write...] try to reuse last bucket if possible, avoiding memory allocation - if needed (not enough space available, not allowed to write in the last bucket), it creates a heap bucket of 8k or more (or transient one if flushed is requested))
   - and then call APR_BRIGADE_INSERT_TAIL

So the 2 constructions are quite similar.


Doing so would:
   + try to use already allocated memory, so reduce memory footprint
   + avoid memory fragmentation by avoiding small buckets
   + reduce code length, so improve readability (IMO)
- BUT, would allocate, when needed, 8k of memory at a time instead of using the memory already available in a pool, so increasing memory footprint...


I haven't done any tests yet, so I don't have measurement on memory usage so far.
Anyway, any thought on this approach would be appreciated.

Best regards,
CJ

Reply via email to