On 13 May 2013, at 22:04, Christophe JAILLET <[email protected]> 
wrote:

> trying to reduce httpd memory usage, I've worked on ap_rgetline_core in 
> protocol.c.
> 
> This function gets a line of protocol input.
> 
> To do so, :
>    - it processes the apr_bucket_brigade it is given in parameter, one bucket 
> at a time
>    - for the common case, it allocates memory to store the data from the 
> bucket, with a minimum on 80 bytes, to try to avoid other memory allocations, 
> should there be other buckets
>    - in case of several buckets and 80 bytes was not enough, it doubles the 
> memory allocated and copy data in the new buffer
> 
> 
> Why is this minimum of 80 bytes there ?
> 
> As stated in the comment, we assume the common case : only 1 bucket.
> According to my testing, with a basic configuration and a simple request, 
> this is the case.
> 
> 
> So, I suggest,
>    *  either to simply remove the test line 293 in protocol.c and the use of 
> MIN_LINE_ALLOC
>             if (current_alloc < MIN_LINE_ALLOC) {
>                 current_alloc = MIN_LINE_ALLOC;
>             }
>       The already in place mechanism will grow the buffer if needed
> 
>    * or, if you prefer to over allocate in case of several buckets, turn it 
> into:
>             if (APR_BUCKET_NEXT(e) != APR_BRIGADE_SENTINEL(bb)) {
>                if (current_alloc < MIN_LINE_ALLOC) {
>                    current_alloc = MIN_LINE_ALLOC;
>                }
>             }
>      to save memory when we know we can.
> 
> 
> Personally, I prefer the first version and drop the test and the use of 
> MIN_LINE_ALLOC.

+1.

Regards,
Graham
--

Reply via email to