summaryrefslogtreecommitdiffstats
path: root/src/extent.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-03-04 06:55:28 (GMT)
committerJason Evans <jasone@canonware.com>2017-03-07 18:25:33 (GMT)
commitcdce93e4a3045bcf0d30409666d2d4c29818aec7 (patch)
treeb30179534e3d70fea704cbeca622ad2dfbdc6b4d /src/extent.c
parentcc75c35db58f4ce4a27455fe5fe46fe9347d2c45 (diff)
downloadjemalloc-cdce93e4a3045bcf0d30409666d2d4c29818aec7.zip
jemalloc-cdce93e4a3045bcf0d30409666d2d4c29818aec7.tar.gz
jemalloc-cdce93e4a3045bcf0d30409666d2d4c29818aec7.tar.bz2
Use any-best-fit for cached extent allocation.
This simplifies what would be pairing heap operations to the equivalent of LIFO queue operations. This is a complementary optimization in the context of delayed coalescing for cached extents.
Diffstat (limited to 'src/extent.c')
-rw-r--r--src/extent.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/extent.c b/src/extent.c
index 368c974..60e385e 100644
--- a/src/extent.c
+++ b/src/extent.c
@@ -238,17 +238,20 @@ extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
}
/*
- * Do first-best-fit extent selection, i.e. select the oldest/lowest extent that
- * best fits.
+ * Do {first,any}-best-fit extent selection, i.e. select the oldest/lowest or
+ * any extent that best fits, where {first,any} corresponds to
+ * extents->delay_coalesce={false,true}.
*/
static extent_t *
-extents_first_best_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents,
+extents_best_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents,
size_t size) {
malloc_mutex_assert_owner(tsdn, &extents->mtx);
pszind_t pind = psz2ind(extent_size_quantize_ceil(size));
for (pszind_t i = pind; i < NPSIZES+1; i++) {
- extent_t *extent = extent_heap_first(&extents->heaps[i]);
+ extent_t *extent = extents->delay_coalesce ?
+ extent_heap_any(&extents->heaps[i]) :
+ extent_heap_first(&extents->heaps[i]);
if (extent != NULL) {
assert(extent_size_get(extent) >= size);
return extent;
@@ -620,7 +623,7 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena,
extent = NULL;
}
} else {
- extent = extents_first_best_fit_locked(tsdn, arena, extents,
+ extent = extents_best_fit_locked(tsdn, arena, extents,
alloc_size);
}
if (extent == NULL) {