Renaming limit_usize_gap to disable_large_size_classes

This commit is contained in:
guangli-dai
2025-04-16 11:57:55 -07:00
committed by Qi Wang
parent 01e9ecbeb2
commit 8347f1045a
18 changed files with 78 additions and 68 deletions

View File

@@ -291,12 +291,12 @@ static inline size_t
edata_usize_get(const edata_t *edata) {
assert(edata != NULL);
/*
* When sz_limit_usize_gap_enabled() is true, two cases:
* When sz_large_size_classes_disabled() is true, two cases:
* 1. if usize_from_ind is not smaller than SC_LARGE_MINCLASS,
* usize_from_size is accurate;
* 2. otherwise, usize_from_ind is accurate.
*
* When sz_limit_usize_gap_enabled() is not true, the two should be the
* When sz_large_size_classes_disabled() is not true, the two should be the
* same when usize_from_ind is not smaller than SC_LARGE_MINCLASS.
*
* Note sampled small allocs will be promoted. Their extent size is
@@ -316,9 +316,9 @@ edata_usize_get(const edata_t *edata) {
}
#endif
if (!sz_limit_usize_gap_enabled() || szind < SC_NBINS) {
if (!sz_large_size_classes_disabled() || szind < SC_NBINS) {
size_t usize_from_ind = sz_index2size(szind);
if (!sz_limit_usize_gap_enabled() &&
if (!sz_large_size_classes_disabled() &&
usize_from_ind >= SC_LARGE_MINCLASS) {
size_t size = (edata->e_size_esn & EDATA_SIZE_MASK);
assert(size > sz_large_pad);
@@ -332,8 +332,8 @@ edata_usize_get(const edata_t *edata) {
assert(size > sz_large_pad);
size_t usize_from_size = size - sz_large_pad;
/*
* no matter limit-usize-gap enabled or not, usize retrieved from size
* is not accurate when smaller than SC_LARGE_MINCLASS.
* no matter large size classes disabled or not, usize retrieved from
* size is not accurate when smaller than SC_LARGE_MINCLASS.
*/
assert(usize_from_size >= SC_LARGE_MINCLASS);
return usize_from_size;

View File

@@ -237,7 +237,7 @@ emap_alloc_ctx_init(emap_alloc_ctx_t *alloc_ctx, szind_t szind, bool slab,
alloc_ctx->szind = szind;
alloc_ctx->slab = slab;
alloc_ctx->usize = usize;
assert(sz_limit_usize_gap_enabled() ||
assert(sz_large_size_classes_disabled() ||
usize == sz_index2size(szind));
}
@@ -248,7 +248,7 @@ emap_alloc_ctx_usize_get(emap_alloc_ctx_t *alloc_ctx) {
assert(alloc_ctx->usize == sz_index2size(alloc_ctx->szind));
return sz_index2size(alloc_ctx->szind);
}
assert(sz_limit_usize_gap_enabled() ||
assert(sz_large_size_classes_disabled() ||
alloc_ctx->usize == sz_index2size(alloc_ctx->szind));
assert(alloc_ctx->usize <= SC_LARGE_MAXCLASS);
return alloc_ctx->usize;

View File

@@ -39,7 +39,7 @@ extern atomic_zu_t zero_realloc_count;
extern bool opt_cache_oblivious;
extern unsigned opt_debug_double_free_max_scan;
extern size_t opt_calloc_madvise_threshold;
extern bool opt_limit_usize_gap;
extern bool opt_disable_large_size_classes;
extern const char *opt_malloc_conf_symlink;
extern const char *opt_malloc_conf_env_var;

View File

@@ -287,11 +287,11 @@
#endif
/*
* When limit_usize_gap is enabled, the gaps between two contiguous
* size classes should not exceed PAGE. This means there should be no concept
* of size classes for sizes > SC_SMALL_MAXCLASS (or >= SC_LARGE_MINCLASS).
* However, between SC_LARGE_MINCLASS (SC_NGROUP * PAGE) and
* 2 * SC_NGROUP * PAGE, the size class also happens to be aligned with PAGE.
* When large size classes are disabled, there is no concept of size classes
* for sizes > SC_SMALLMAXCLASS (or >= SC_LARGE_MINCLASS). This ensures that
* the overhead between the usable size and the user request size will not
* exceed PAGE. Between SC_LARGE_MINCLASS (SC_NGROUP * PAGE) and
* 2 * SC_NGROUP * PAGE, the size classes also happen to be aligned with PAGE.
* Since tcache relies on size classes to work and it greatly increases the
* perf of allocs & deallocs, we extend the existence of size class to
* 2 * SC_NGROUP * PAGE ONLY for the tcache module. This means for all other

View File

@@ -55,8 +55,8 @@ extern size_t sz_large_pad;
extern void sz_boot(const sc_data_t *sc_data, bool cache_oblivious);
JEMALLOC_ALWAYS_INLINE bool
sz_limit_usize_gap_enabled() {
return opt_limit_usize_gap;
sz_large_size_classes_disabled() {
return opt_disable_large_size_classes;
}
JEMALLOC_ALWAYS_INLINE pszind_t
@@ -269,11 +269,11 @@ sz_index2size_unsafe(szind_t index) {
JEMALLOC_ALWAYS_INLINE size_t
sz_index2size(szind_t index) {
assert(!sz_limit_usize_gap_enabled() ||
assert(!sz_large_size_classes_disabled() ||
index <= sz_size2index(USIZE_GROW_SLOW_THRESHOLD));
size_t size = sz_index2size_unsafe(index);
/*
* With limit_usize_gap enabled, the usize above
* With large size classes disabled, the usize above
* SC_LARGE_MINCLASS should grow by PAGE. However, for sizes
* in [SC_LARGE_MINCLASS, USIZE_GROW_SLOW_THRESHOLD], the
* usize would not change because the size class gap in this
@@ -285,7 +285,7 @@ sz_index2size(szind_t index) {
* the size is no larger than USIZE_GROW_SLOW_THRESHOLD here
* instead of SC_LARGE_MINCLASS.
*/
assert(!sz_limit_usize_gap_enabled() ||
assert(!sz_large_size_classes_disabled() ||
size <= USIZE_GROW_SLOW_THRESHOLD);
return size;
}
@@ -335,11 +335,11 @@ sz_s2u_compute(size_t size) {
(ZU(1) << lg_ceil));
}
#endif
if (size <= SC_SMALL_MAXCLASS || !sz_limit_usize_gap_enabled()) {
if (size <= SC_SMALL_MAXCLASS || !sz_large_size_classes_disabled()) {
return sz_s2u_compute_using_delta(size);
} else {
/*
* With sz_limit_usize_gap_enabled() == true, usize of a large
* With sz_large_size_classes_disabled() == true, usize of a large
* allocation is calculated by ceiling size to the smallest
* multiple of PAGE to minimize the memory overhead, especially
* when using hugepages.