Re: [PATCH] Remove MemPools use of calloc()

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Sat, 12 Jan 2013 23:17:22 +1300

On 11/01/2013 8:34 p.m., Amos Jeffries wrote:
> As we are closing defects identified by Coverity and improving
> constructors everywhere we are creating a minor anti-pattern in
> MemPool'ed objects with calloc() in the pool initializing the memory
> then constructors re-initializing it in a better way for that object.
>
> MemPools contains a doZeroOnPush flag to optimize performance by
> removing use of memset() as chunks are added back into the pool.
> However, on closer inspection it is clear that the following pop()
> process to re-use those chunks is never performing memset() anyway. As
> such I believe that there is no special need to use calloc() on these
> particular object types in the first place.
>
> The attached patch updates MemPools to use malloc() instead of
> calloc() on all types with doZeroOnPush set. This should increase
> performance a little, and allows us to remove the anti-pattern by
> setting doZeroOnPush for more objects as we can verify they are
> correctly initialized by their constructors.
>
> Amos
>

Updated patch which actually builds the MemPoolChunked class :-(

Amos

Received on Sat Jan 12 2013 - 10:17:37 MST

This archive was generated by hypermail 2.2.0 : Sat Jan 12 2013 - 12:00:10 MST