git: libc - Improve realloc() performance.

Matthew Dillon dillon at crater.dragonflybsd.org
Wed Feb 17 10:39:41 PST 2016


commit 07a8ffeaab3fc830679c6836a6ee198ad1a3275f
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(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/07a8ffeaab3fc830679c6836a6ee198ad1a3275f


-- 
DragonFly BSD source repository


More information about the Commits mailing list