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.
This commit is contained in:
parent
cc75c35db5
commit
cdce93e4a3
13
src/extent.c
13
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
|
* Do {first,any}-best-fit extent selection, i.e. select the oldest/lowest or
|
||||||
* best fits.
|
* any extent that best fits, where {first,any} corresponds to
|
||||||
|
* extents->delay_coalesce={false,true}.
|
||||||
*/
|
*/
|
||||||
static extent_t *
|
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) {
|
size_t size) {
|
||||||
malloc_mutex_assert_owner(tsdn, &extents->mtx);
|
malloc_mutex_assert_owner(tsdn, &extents->mtx);
|
||||||
|
|
||||||
pszind_t pind = psz2ind(extent_size_quantize_ceil(size));
|
pszind_t pind = psz2ind(extent_size_quantize_ceil(size));
|
||||||
for (pszind_t i = pind; i < NPSIZES+1; i++) {
|
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) {
|
if (extent != NULL) {
|
||||||
assert(extent_size_get(extent) >= size);
|
assert(extent_size_get(extent) >= size);
|
||||||
return extent;
|
return extent;
|
||||||
@ -620,7 +623,7 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena,
|
|||||||
extent = NULL;
|
extent = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
extent = extents_first_best_fit_locked(tsdn, arena, extents,
|
extent = extents_best_fit_locked(tsdn, arena, extents,
|
||||||
alloc_size);
|
alloc_size);
|
||||||
}
|
}
|
||||||
if (extent == NULL) {
|
if (extent == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user