mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-27 22:33:15 +03:00
Add a hard limit on tcache max size class.
For locality reasons, tcache bins are integrated in TSD. Allowing all size classes to be cached has little benefit, but takes up much thread local storage. In addition, it complicates the layout which we try hard to optimize.
This commit is contained in:
parent
3de19ba401
commit
5e41ff9b74
4 changed files with 14 additions and 9 deletions
12
src/tcache.c
12
src/tcache.c
|
|
@ -936,20 +936,20 @@ tcache_ncached_max_compute(szind_t szind) {
|
|||
bool
|
||||
tcache_boot(tsdn_t *tsdn, base_t *base) {
|
||||
/* If necessary, clamp opt_lg_tcache_max. */
|
||||
if (opt_lg_tcache_max < 0 || (ZU(1) << opt_lg_tcache_max) <
|
||||
SC_SMALL_MAXCLASS) {
|
||||
tcache_maxclass = opt_lg_tcache_max < 0 ? 0 :
|
||||
ZU(1) << opt_lg_tcache_max;
|
||||
if (tcache_maxclass < SC_SMALL_MAXCLASS) {
|
||||
tcache_maxclass = SC_SMALL_MAXCLASS;
|
||||
} else {
|
||||
tcache_maxclass = (ZU(1) << opt_lg_tcache_max);
|
||||
} else if (tcache_maxclass > TCACHE_MAXCLASS_LIMIT) {
|
||||
tcache_maxclass = TCACHE_MAXCLASS_LIMIT;
|
||||
}
|
||||
nhbins = sz_size2index(tcache_maxclass) + 1;
|
||||
|
||||
if (malloc_mutex_init(&tcaches_mtx, "tcaches", WITNESS_RANK_TCACHES,
|
||||
malloc_mutex_rank_exclusive)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nhbins = sz_size2index(tcache_maxclass) + 1;
|
||||
|
||||
/* Initialize tcache_bin_info. */
|
||||
tcache_bin_info = (cache_bin_info_t *)base_alloc(tsdn, base,
|
||||
nhbins * sizeof(cache_bin_info_t), CACHELINE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue