libc: nmalloc - Add a per-thread magazine layer and a malloc slab magazine.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Thu, 9 Sep 2010 10:51:28 +0000 (03:51 -0700)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Thu, 9 Sep 2010 10:51:28 +0000 (03:51 -0700)
commit0bb7d8c82a64940013681cf515d16f3e62eb7e3c
tree3322823fd46937f93d312ad162fd2b54188eaf69
parentd124f09d8a603db22b85128bbbd40cd40de312a0
libc: nmalloc - Add a per-thread magazine layer and a malloc slab magazine.

The per-thread magazine layer is based on the Solaris umem/vmem paper; it
creates fixed-sized arrays ('magazines') of buffers and binds them to threads.
Local allocations can often now occur with minimal locking and interference.

The slab magazine is meant to buffer calls calls to mmap when requesting slabs.
In tests with MySQL/sysbench OLTP, it leads to fairly dramatic reductions in
the total number of mmap system calls.

nmalloc now also respects the MALLOC_OPTIONS environment variable:
- The 'U' option generates ktrace entries for all malloc/realloc/free calls
- The 'H' option calls madvise liberally to return pages to the system often
- The 'Z' option zeroes all allocations

This work was developed out-of-tree; the RCS log is on leaf.
lib/libc/stdlib/nmalloc.c