On 16.12.2006, at 16:25, Stephen Deasey wrote:
Something to think about: does the nedmalloc test include allocating memory in one thread and freeing it in another? Apparently this is tough for some allocators, such as Linux ptmalloc. Naviserver does this.
I'm still not 100% ready reading the code but: The Tcl allocator just puts the free'd memory in the cache of the current thread that calls free(). On thread exit, or of the size of the cache exceeds some limit, the content of the cache is appended to shared cache. The memory is never returned to the system, unless it is allocated as a chunk larger that 16K. The nedmalloc does the same but does not move freed memory between the per-thread cache and the shared repository. Instead, the thread cache is emptied (freed) when a thread exits. This must be explicitly called by the user. As I see: all is green. But will pay more attention to that by reading the code more carefully... Perhaps there is some gotcha there which I would not like to discover at the customer site ;-) In nedmalloc you can disable the per-thread cache usage by defining -DTHREADCACHEMAX=0 during compilation. This makes some difference: Testing nedmalloc with 5 threads ... This allocator achieves 16194016.581962ops/sec under 5 threads w/o cache versus Testing nedmalloc with 5 threads ... This allocator achieves 18895753.973492ops/sec under 5 threads with the cache. The THREADCACHEMAX defines the size of the allocation which goes into cache, similarily to the zippy. The default is 8K (vs. 16K with zippy). The above figures were done with max 8K size. If you increase it to 16K the malloc cores :-( Too bad. Still, I believe that for long running processes, the approach of never releasing memory to the OS, as zippy is doing, is suboptimal. Speed here or there, I'd rather save myself process reboots if possible... Bad thing is that Tcl allocator (aka zippy) will not allow me any choice but bloat. And this is becomming more and more important. At some customers site I have observed process sizes of 1.5GB whereas we started with about 80MB. Eh!