Move delay_coalesce from the eset to the ecache.
This commit is contained in:
parent
bb70df8e5b
commit
98eb40e563
@ -8,6 +8,11 @@ typedef struct ecache_s ecache_t;
|
|||||||
struct ecache_s {
|
struct ecache_s {
|
||||||
malloc_mutex_t mtx;
|
malloc_mutex_t mtx;
|
||||||
eset_t eset;
|
eset_t eset;
|
||||||
|
/*
|
||||||
|
* If true, delay coalescing until eviction; otherwise coalesce during
|
||||||
|
* deallocation.
|
||||||
|
*/
|
||||||
|
bool delay_coalesce;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ecache_grow_s ecache_grow_t;
|
typedef struct ecache_grow_s ecache_grow_t;
|
||||||
|
@ -32,15 +32,9 @@ struct eset_s {
|
|||||||
|
|
||||||
/* All stored extents must be in the same state. */
|
/* All stored extents must be in the same state. */
|
||||||
extent_state_t state;
|
extent_state_t state;
|
||||||
|
|
||||||
/*
|
|
||||||
* If true, delay coalescing until eviction; otherwise coalesce during
|
|
||||||
* deallocation.
|
|
||||||
*/
|
|
||||||
bool delay_coalesce;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void eset_init(eset_t *eset, extent_state_t state, bool delay_coalesce);
|
void eset_init(eset_t *eset, extent_state_t state);
|
||||||
extent_state_t eset_state_get(const eset_t *eset);
|
extent_state_t eset_state_get(const eset_t *eset);
|
||||||
|
|
||||||
size_t eset_npages_get(eset_t *eset);
|
size_t eset_npages_get(eset_t *eset);
|
||||||
@ -55,6 +49,7 @@ void eset_remove(eset_t *eset, edata_t *edata);
|
|||||||
* Select an extent from this eset of the given size and alignment. Returns
|
* Select an extent from this eset of the given size and alignment. Returns
|
||||||
* null if no such item could be found.
|
* null if no such item could be found.
|
||||||
*/
|
*/
|
||||||
edata_t *eset_fit(eset_t *eset, size_t esize, size_t alignment);
|
edata_t *eset_fit(eset_t *eset, size_t esize, size_t alignment,
|
||||||
|
bool delay_coalesce);
|
||||||
|
|
||||||
#endif /* JEMALLOC_INTERNAL_ESET_H */
|
#endif /* JEMALLOC_INTERNAL_ESET_H */
|
||||||
|
@ -8,7 +8,8 @@ ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state,
|
|||||||
malloc_mutex_rank_exclusive)) {
|
malloc_mutex_rank_exclusive)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
eset_init(&ecache->eset, state, delay_coalesce);
|
ecache->delay_coalesce = delay_coalesce;
|
||||||
|
eset_init(&ecache->eset, state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/eset.c
12
src/eset.c
@ -9,8 +9,7 @@ const bitmap_info_t eset_bitmap_info =
|
|||||||
BITMAP_INFO_INITIALIZER(SC_NPSIZES+1);
|
BITMAP_INFO_INITIALIZER(SC_NPSIZES+1);
|
||||||
|
|
||||||
void
|
void
|
||||||
eset_init(eset_t *eset, extent_state_t state,
|
eset_init(eset_t *eset, extent_state_t state) {
|
||||||
bool delay_coalesce) {
|
|
||||||
for (unsigned i = 0; i < SC_NPSIZES + 1; i++) {
|
for (unsigned i = 0; i < SC_NPSIZES + 1; i++) {
|
||||||
edata_heap_new(&eset->heaps[i]);
|
edata_heap_new(&eset->heaps[i]);
|
||||||
}
|
}
|
||||||
@ -18,7 +17,6 @@ eset_init(eset_t *eset, extent_state_t state,
|
|||||||
edata_list_init(&eset->lru);
|
edata_list_init(&eset->lru);
|
||||||
atomic_store_zu(&eset->npages, 0, ATOMIC_RELAXED);
|
atomic_store_zu(&eset->npages, 0, ATOMIC_RELAXED);
|
||||||
eset->state = state;
|
eset->state = state;
|
||||||
eset->delay_coalesce = delay_coalesce;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extent_state_t
|
extent_state_t
|
||||||
@ -163,7 +161,7 @@ eset_fit_alignment(eset_t *eset, size_t min_size, size_t max_size,
|
|||||||
* large enough.
|
* large enough.
|
||||||
*/
|
*/
|
||||||
static edata_t *
|
static edata_t *
|
||||||
eset_first_fit(eset_t *eset, size_t size) {
|
eset_first_fit(eset_t *eset, size_t size, bool delay_coalesce) {
|
||||||
edata_t *ret = NULL;
|
edata_t *ret = NULL;
|
||||||
|
|
||||||
pszind_t pind = sz_psz2ind(sz_psz_quantize_ceil(size));
|
pszind_t pind = sz_psz2ind(sz_psz_quantize_ceil(size));
|
||||||
@ -191,7 +189,7 @@ eset_first_fit(eset_t *eset, size_t size) {
|
|||||||
*
|
*
|
||||||
* Only do check for dirty eset (delay_coalesce).
|
* Only do check for dirty eset (delay_coalesce).
|
||||||
*/
|
*/
|
||||||
if (eset->delay_coalesce &&
|
if (delay_coalesce &&
|
||||||
(sz_pind2sz(i) >> opt_lg_extent_max_active_fit) > size) {
|
(sz_pind2sz(i) >> opt_lg_extent_max_active_fit) > size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -208,14 +206,14 @@ eset_first_fit(eset_t *eset, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
edata_t *
|
edata_t *
|
||||||
eset_fit(eset_t *eset, size_t esize, size_t alignment) {
|
eset_fit(eset_t *eset, size_t esize, size_t alignment, bool delay_coalesce) {
|
||||||
size_t max_size = esize + PAGE_CEILING(alignment) - PAGE;
|
size_t max_size = esize + PAGE_CEILING(alignment) - PAGE;
|
||||||
/* Beware size_t wrap-around. */
|
/* Beware size_t wrap-around. */
|
||||||
if (max_size < esize) {
|
if (max_size < esize) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
edata_t *edata = eset_first_fit(eset, max_size);
|
edata_t *edata = eset_first_fit(eset, max_size, delay_coalesce);
|
||||||
|
|
||||||
if (alignment > PAGE && edata == NULL) {
|
if (alignment > PAGE && edata == NULL) {
|
||||||
/*
|
/*
|
||||||
|
@ -235,7 +235,7 @@ extents_evict(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, ecache_t *ecache,
|
|||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
eset_remove(&ecache->eset, edata);
|
eset_remove(&ecache->eset, edata);
|
||||||
if (!ecache->eset.delay_coalesce) {
|
if (!ecache->delay_coalesce) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Try to coalesce. */
|
/* Try to coalesce. */
|
||||||
@ -563,7 +563,8 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
extent_unlock_edata(tsdn, unlock_edata);
|
extent_unlock_edata(tsdn, unlock_edata);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
edata = eset_fit(&ecache->eset, esize, alignment);
|
edata = eset_fit(&ecache->eset, esize, alignment,
|
||||||
|
ecache->delay_coalesce);
|
||||||
}
|
}
|
||||||
if (edata == NULL) {
|
if (edata == NULL) {
|
||||||
malloc_mutex_unlock(tsdn, &ecache->mtx);
|
malloc_mutex_unlock(tsdn, &ecache->mtx);
|
||||||
@ -1127,7 +1128,7 @@ extent_try_coalesce_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
if (can_coalesce && !extent_coalesce(tsdn, arena,
|
if (can_coalesce && !extent_coalesce(tsdn, arena,
|
||||||
ehooks, ecache, edata, next, true,
|
ehooks, ecache, edata, next, true,
|
||||||
growing_retained)) {
|
growing_retained)) {
|
||||||
if (ecache->eset.delay_coalesce) {
|
if (ecache->delay_coalesce) {
|
||||||
/* Do minimal coalescing. */
|
/* Do minimal coalescing. */
|
||||||
*coalesced = true;
|
*coalesced = true;
|
||||||
return edata;
|
return edata;
|
||||||
@ -1148,7 +1149,7 @@ extent_try_coalesce_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
ehooks, ecache, edata, prev, false,
|
ehooks, ecache, edata, prev, false,
|
||||||
growing_retained)) {
|
growing_retained)) {
|
||||||
edata = prev;
|
edata = prev;
|
||||||
if (ecache->eset.delay_coalesce) {
|
if (ecache->delay_coalesce) {
|
||||||
/* Do minimal coalescing. */
|
/* Do minimal coalescing. */
|
||||||
*coalesced = true;
|
*coalesced = true;
|
||||||
return edata;
|
return edata;
|
||||||
@ -1158,7 +1159,7 @@ extent_try_coalesce_impl(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks,
|
|||||||
}
|
}
|
||||||
} while (again);
|
} while (again);
|
||||||
|
|
||||||
if (ecache->eset.delay_coalesce) {
|
if (ecache->delay_coalesce) {
|
||||||
*coalesced = false;
|
*coalesced = false;
|
||||||
}
|
}
|
||||||
return edata;
|
return edata;
|
||||||
@ -1205,7 +1206,7 @@ extent_record(tsdn_t *tsdn, arena_t *arena, ehooks_t *ehooks, ecache_t *ecache,
|
|||||||
assert(rtree_edata_read(tsdn, &extents_rtree, rtree_ctx,
|
assert(rtree_edata_read(tsdn, &extents_rtree, rtree_ctx,
|
||||||
(uintptr_t)edata_base_get(edata), true) == edata);
|
(uintptr_t)edata_base_get(edata), true) == edata);
|
||||||
|
|
||||||
if (!ecache->eset.delay_coalesce) {
|
if (!ecache->delay_coalesce) {
|
||||||
edata = extent_try_coalesce(tsdn, arena, ehooks, rtree_ctx,
|
edata = extent_try_coalesce(tsdn, arena, ehooks, rtree_ctx,
|
||||||
ecache, edata, NULL, growing_retained);
|
ecache, edata, NULL, growing_retained);
|
||||||
} else if (edata_size_get(edata) >= SC_LARGE_MINCLASS) {
|
} else if (edata_size_get(edata) >= SC_LARGE_MINCLASS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user