]> git.ipfire.org Git - thirdparty/squid.git/commit - src/mem/PoolMalloc.cc
MemPools: remove zero on allocate (calloc) from some pool types
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 14 Jan 2013 05:01:04 +0000 (22:01 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 14 Jan 2013 05:01:04 +0000 (22:01 -0700)
commit3b08e399e164a37e16ea36a560d12fd7f44b48fe
tree4bccd444db6b49c2e4def1c2b7738d1d9738108c
parent3af9db3fd83a544a9ea615024a50ebed0e2abd5b
MemPools: remove zero on allocate (calloc) from some pool types

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.

Update 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.
include/MemPool.h
lib/MemPool.cc
lib/MemPoolChunked.cc
lib/MemPoolMalloc.cc
src/Mem.h
src/mem.cc