httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: [request for comments ] performance issue : calloc & free vs creating subpool for cache memory management???
Date Tue, 13 Jul 2004 15:27:02 GMT
At 06:55 AM 7/13/2004, Sadaf Alvi wrote:
>i wanna write a cache library and come up with 2 different techniques to allocate cache
memory
>1) use calloc & free for each node 
>2) create a subpool in pconf for each node 

What your test fails to convey is that alloc and free of one pool is quite
likely slower than alloc()/free(), but this is not how/why pools are used.

Let's assume each cache unit is allocated as a single alloc/free.  Then
your benchmark is correct, use alloc()/free().

If we assume your cache units are composites which require an arbitrary
number of allocs, then you will begin to see a benefit to pools.  Rather
than multiple free's - cleaning out the entire pool at once is more efficient.
The pool cleanup also offers you a chance to implement destructor-like
behavior for your pool objects.






Mime
View raw message