git: libc - Improve realloc() performance.
dillon at crater.dragonflybsd.org
Wed Feb 17 10:39:41 PST 2016
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Tue Feb 16 20:40:44 2016 -0800
libc - Improve realloc() performance.
* Oversized free()'s <= 1MB will be cached in a 16-entry array. Any oversized
allocation can make use of the cache, even if available cache entries are
significantly larger than desired, in order to accomodate application
buffer-growing behavior. This means that applications which realloc() a
lot (at least as long as the buffer is <= 1MB) will wind up being handed
a ~1MB buffer quite frequently, eliminating new mmap() operations.
* Keeps track of the excess in oversized allocations and will garbage-collect
it if it grows too large (typically > 16MB). This is primarily what allows
us to be generous.
* realloc() will attempt to use MAP_TRYFIXED to extend an oversized allocation
before giving up and remapping it.
* Improves programs which realloc() or malloc()/free() large numbers of
oversized blocks by reducing or eliminating mmap()/munmap() calls.
Summary of changes:
lib/libc/stdlib/nmalloc.c | 250 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 227 insertions(+), 23 deletions(-)
DragonFly BSD source repository
More information about the Commits