apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: [PATCH] greener apr allocator
Date Mon, 07 Apr 2008 10:18:17 GMT
On Fri, Jan 04, 2008 at 11:02:26AM +0000, Maxim Yegorushkin wrote:
> Summary of changes:
> 
> * There is a bug in several memory allocation functions in apr_pools.c,
>   where memory request size is compared with free memory available from the
>   node this way:
> 
>     /* If the active node has enough bytes left, use it. */
>     if (size < (apr_size_t)(active->endp - active->first_avail)) {
> 
>   Thus, if size is 8 and the active node has 8 bytes left free, the strict
>   comparison yields false. The comparisons changed to <=. This change
>   provides extra 8 bytes of memory to the user (since the minimum allocation
>   size is 8).

Good catch!  I've committed your changes which fix this and factor out 
the code to check it.

> * apr_memnode_t structure cleaned up.
> 
>   apr_memnode_t::endp member has been removed. Instead, the value is
>   calculated this way:
...

I'm a bit wary about this; it trades off CPU for memory, so I'm forced 
to ask: what's the performance impact?

> * allocator_alloc() has been refactored to eliminate race conditions. It
>   used to hold the mutex while changing apr_allocator_t members, but not
>   while reading.
>
> * Some duplicate code was extracted into functions. apr_pool.c code is now
>   63 lines shorter.

I can't quite follow all these changes because it's all in one big 
patch.  Any chance you could split it up into several 
functionally-separate patches?

Regards,

joe

Mime
View raw message