Allow opt.tcache_max to accept small size classes.

Previously all the small size classes were cached.  However this has downsides
-- particularly when page size is greater than 4K (e.g. iOS), which will result
in much higher SMALL_MAXCLASS.

This change allows tcache_max to be set to lower values, to better control
resources taken by tcache.
This commit is contained in:
Qi Wang
2020-10-21 19:47:57 -07:00
committed by Qi Wang
parent ea32060f9c
commit bf72188f80
10 changed files with 265 additions and 33 deletions

View File

@@ -432,7 +432,6 @@ TEST_BEGIN(test_decay_ticker) {
unsigned arena_ind = do_arena_create(ddt, mdt);
int flags = (MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE);
void *ps[NPS];
size_t large;
/*
* Allocate a bunch of large objects, pause the clock, deallocate every
@@ -440,12 +439,10 @@ TEST_BEGIN(test_decay_ticker) {
* [md]allocx() in a tight loop while advancing time rapidly to verify
* the ticker triggers purging.
*/
size_t tcache_max;
size_t large;
size_t sz = sizeof(size_t);
expect_d_eq(mallctl("arenas.tcache_max", (void *)&tcache_max, &sz, NULL,
expect_d_eq(mallctl("arenas.lextent.0.size", (void *)&large, &sz, NULL,
0), 0, "Unexpected mallctl failure");
large = nallocx(tcache_max + 1, flags);
do_purge(arena_ind);
uint64_t dirty_npurge0 = get_arena_dirty_npurge(arena_ind);