diff options
author | Qi Wang <interwq@gwu.edu> | 2017-11-09 21:51:39 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-11-16 23:32:02 (GMT) |
commit | fac706836ffda46759914508b918e8b54c8020c8 (patch) | |
tree | dd99c6e68c7d34559d7f90a433aec0529b22e6f9 /src/extent.c | |
parent | 282a3faa1784783e2e2cb3698183927b3927b950 (diff) | |
download | jemalloc-fac706836ffda46759914508b918e8b54c8020c8.zip jemalloc-fac706836ffda46759914508b918e8b54c8020c8.tar.gz jemalloc-fac706836ffda46759914508b918e8b54c8020c8.tar.bz2 |
Add opt.lg_extent_max_active_fit
When allocating from dirty extents (which we always prefer if available), large
active extents can get split even if the new allocation is much smaller, in
which case the introduced fragmentation causes high long term damage. This new
option controls the threshold to reuse and split an existing active extent. We
avoid using a large extent for much smaller sizes, in order to reduce
fragmentation. In some workload, adding the threshold improves virtual memory
usage by >10x.
Diffstat (limited to 'src/extent.c')
-rw-r--r-- | src/extent.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/extent.c b/src/extent.c index 466e0b2..548a93e 100644 --- a/src/extent.c +++ b/src/extent.c @@ -17,6 +17,8 @@ rtree_t extents_rtree; /* Keyed by the address of the extent_t being protected. */ mutex_pool_t extent_mutex_pool; +size_t opt_lg_extent_max_active_fit = LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT; + static const bitmap_info_t extents_bitmap_info = BITMAP_INFO_INITIALIZER(NPSIZES+1); @@ -369,6 +371,13 @@ extents_best_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, pszind_t i = (pszind_t)bitmap_ffu(extents->bitmap, &extents_bitmap_info, (size_t)pind); if (i < NPSIZES+1) { + /* + * In order to reduce fragmentation, avoid reusing and splitting + * large extents for much smaller sizes. + */ + if ((sz_pind2sz(i) >> opt_lg_extent_max_active_fit) > size) { + return NULL; + } assert(!extent_heap_empty(&extents->heaps[i])); extent_t *extent = extent_heap_first(&extents->heaps[i]); assert(extent_size_get(extent) >= size); |