diff options
author | Jason Evans <je@fb.com> | 2011-03-21 07:18:17 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2011-03-21 07:18:17 (GMT) |
commit | 1dcb4f86b23a5760f5a717ace716360b63b33fad (patch) | |
tree | 8bce971a06b3d2a9325e04f748d5dc0591ba5a2d /jemalloc/src | |
parent | 893a0ed7c8c11962524ba6f2adeb304d038be2a9 (diff) | |
download | jemalloc-1dcb4f86b23a5760f5a717ace716360b63b33fad.zip jemalloc-1dcb4f86b23a5760f5a717ace716360b63b33fad.tar.gz jemalloc-1dcb4f86b23a5760f5a717ace716360b63b33fad.tar.bz2 |
Dynamically adjust tcache fill count.
Dynamically adjust tcache fill count (number of objects allocated per
tcache refill) such that if GC has to flush inactive objects, the fill
count gradually decreases. Conversely, if refills occur while the fill
count is depressed, the fill count gradually increases back to its
maximum value.
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/arena.c | 7 | ||||
-rw-r--r-- | jemalloc/src/tcache.c | 5 |
2 files changed, 6 insertions, 6 deletions
diff --git a/jemalloc/src/arena.c b/jemalloc/src/arena.c index 4cbca57..0f4f12a 100644 --- a/jemalloc/src/arena.c +++ b/jemalloc/src/arena.c @@ -1386,8 +1386,8 @@ arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, size_t binind #endif bin = &arena->bins[binind]; malloc_mutex_lock(&bin->lock); - for (i = 0, nfill = (tcache_bin_info[binind].ncached_max >> 1); - i < nfill; i++) { + for (i = 0, nfill = (tcache_bin_info[binind].ncached_max >> + tbin->lg_fill_div); i < nfill; i++) { if ((run = bin->runcur) != NULL && run->nfree > 0) ptr = arena_run_reg_alloc(run, &arena_bin_info[binind]); else @@ -1398,8 +1398,7 @@ arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, size_t binind tbin->avail[nfill - 1 - i] = ptr; } #ifdef JEMALLOC_STATS - bin->stats.allocated += (i - tbin->ncached) * - arena_bin_info[binind].reg_size; + bin->stats.allocated += i * arena_bin_info[binind].reg_size; bin->stats.nmalloc += i; bin->stats.nrequests += tbin->tstats.nrequests; bin->stats.nfills++; diff --git a/jemalloc/src/tcache.c b/jemalloc/src/tcache.c index 2f4804e..31c329e 100644 --- a/jemalloc/src/tcache.c +++ b/jemalloc/src/tcache.c @@ -135,7 +135,7 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem memmove(tbin->avail, &tbin->avail[tbin->ncached - rem], rem * sizeof(void *)); tbin->ncached = rem; - if (tbin->ncached < tbin->low_water) + if ((int)tbin->ncached < tbin->low_water) tbin->low_water = tbin->ncached; } @@ -218,7 +218,7 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem memmove(tbin->avail, &tbin->avail[tbin->ncached - rem], rem * sizeof(void *)); tbin->ncached = rem; - if (tbin->ncached < tbin->low_water) + if ((int)tbin->ncached < tbin->low_water) tbin->low_water = tbin->ncached; } @@ -265,6 +265,7 @@ tcache_create(arena_t *arena) tcache->arena = arena; assert((TCACHE_NSLOTS_SMALL_MAX & 1U) == 0); for (i = 0; i < nhbins; i++) { + tcache->tbins[i].lg_fill_div = 1; tcache->tbins[i].avail = (void **)((uintptr_t)tcache + (uintptr_t)stack_offset); stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *); |