Eset: Parameterize last globals accesses.

I.e. opt_retain and maps_coalesce.
This commit is contained in:
David Goldblatt 2020-03-14 10:05:12 -07:00 committed by David Goldblatt
parent 7bb6e2dc0d
commit f730577277
3 changed files with 14 additions and 12 deletions

View File

@ -51,7 +51,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 exact_only,
unsigned lg_max_fit); unsigned lg_max_fit);
#endif /* JEMALLOC_INTERNAL_ESET_H */ #endif /* JEMALLOC_INTERNAL_ESET_H */

View File

@ -2,8 +2,6 @@
#include "jemalloc/internal/jemalloc_internal_includes.h" #include "jemalloc/internal/jemalloc_internal_includes.h"
#include "jemalloc/internal/eset.h" #include "jemalloc/internal/eset.h"
/* For opt_retain */
#include "jemalloc/internal/extent_mmap.h"
const bitmap_info_t eset_bitmap_info = const bitmap_info_t eset_bitmap_info =
BITMAP_INFO_INITIALIZER(SC_NPSIZES+1); BITMAP_INFO_INITIALIZER(SC_NPSIZES+1);
@ -162,16 +160,13 @@ eset_fit_alignment(eset_t *eset, size_t min_size, size_t max_size,
* for others. * for others.
*/ */
static edata_t * static edata_t *
eset_first_fit(eset_t *eset, size_t size, unsigned lg_max_fit) { eset_first_fit(eset_t *eset, size_t size, bool exact_only,
unsigned lg_max_fit) {
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));
if (!maps_coalesce && !opt_retain) { if (exact_only) {
/*
* No split / merge allowed (Windows w/o retain). Try exact fit
* only.
*/
return edata_heap_empty(&eset->heaps[pind]) ? NULL : return edata_heap_empty(&eset->heaps[pind]) ? NULL :
edata_heap_first(&eset->heaps[pind]); edata_heap_first(&eset->heaps[pind]);
} }
@ -208,14 +203,15 @@ eset_first_fit(eset_t *eset, size_t size, unsigned lg_max_fit) {
} }
edata_t * edata_t *
eset_fit(eset_t *eset, size_t esize, size_t alignment, unsigned lg_max_fit) { eset_fit(eset_t *eset, size_t esize, size_t alignment, bool exact_only,
unsigned lg_max_fit) {
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, lg_max_fit); edata_t *edata = eset_first_fit(eset, max_size, exact_only, lg_max_fit);
if (alignment > PAGE && edata == NULL) { if (alignment > PAGE && edata == NULL) {
/* /*

View File

@ -398,6 +398,11 @@ extent_recycle_extract(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks,
emap_unlock_edata(tsdn, &emap_global, unlock_edata); emap_unlock_edata(tsdn, &emap_global, unlock_edata);
} }
} else { } else {
/*
* If split and merge are not allowed (Windows w/o retain), try
* exact fit only.
*/
bool exact_only = (!maps_coalesce && !opt_retain);
/* /*
* A large extent might be broken up from its original size to * A large extent might be broken up from its original size to
* some small size to satisfy a small request. When that small * some small size to satisfy a small request. When that small
@ -409,7 +414,8 @@ extent_recycle_extract(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks,
*/ */
unsigned lg_max_fit = ecache->delay_coalesce unsigned lg_max_fit = ecache->delay_coalesce
? (unsigned)opt_lg_extent_max_active_fit : SC_PTR_BITS; ? (unsigned)opt_lg_extent_max_active_fit : SC_PTR_BITS;
edata = eset_fit(&ecache->eset, size, alignment, lg_max_fit); edata = eset_fit(&ecache->eset, size, alignment, exact_only,
lg_max_fit);
} }
if (edata == NULL) { if (edata == NULL) {
malloc_mutex_unlock(tsdn, &ecache->mtx); malloc_mutex_unlock(tsdn, &ecache->mtx);