Fix arena reset effects on large/huge stats.
Reset large curruns to 0 during arena reset. Do not increase huge ndalloc stats during arena reset.
This commit is contained in:
parent
2fe64d237c
commit
7e6749595a
29
src/arena.c
29
src/arena.c
@ -854,6 +854,17 @@ arena_huge_dalloc_stats_update(arena_t *arena, size_t usize)
|
|||||||
arena->stats.hstats[index].curhchunks--;
|
arena->stats.hstats[index].curhchunks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
arena_huge_reset_stats_cancel(arena_t *arena, size_t usize)
|
||||||
|
{
|
||||||
|
szind_t index = size2index(usize) - nlclasses - NBINS;
|
||||||
|
|
||||||
|
cassert(config_stats);
|
||||||
|
|
||||||
|
arena->stats.ndalloc_huge++;
|
||||||
|
arena->stats.hstats[index].ndalloc--;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
arena_huge_dalloc_stats_update_undo(arena_t *arena, size_t usize)
|
arena_huge_dalloc_stats_update_undo(arena_t *arena, size_t usize)
|
||||||
{
|
{
|
||||||
@ -1884,22 +1895,30 @@ arena_reset(tsd_t *tsd, arena_t *arena)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset curruns for large size classes. */
|
||||||
|
if (config_stats) {
|
||||||
|
for (i = 0; i < nlclasses; i++)
|
||||||
|
arena->stats.lstats[i].curruns = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Huge allocations. */
|
/* Huge allocations. */
|
||||||
malloc_mutex_lock(tsd, &arena->huge_mtx);
|
malloc_mutex_lock(tsd, &arena->huge_mtx);
|
||||||
for (node = ql_last(&arena->huge, ql_link); node != NULL; node =
|
for (node = ql_last(&arena->huge, ql_link); node != NULL; node =
|
||||||
ql_last(&arena->huge, ql_link)) {
|
ql_last(&arena->huge, ql_link)) {
|
||||||
void *ptr = extent_node_addr_get(node);
|
void *ptr = extent_node_addr_get(node);
|
||||||
|
size_t usize;
|
||||||
|
|
||||||
malloc_mutex_unlock(tsd, &arena->huge_mtx);
|
malloc_mutex_unlock(tsd, &arena->huge_mtx);
|
||||||
/* Remove huge allocation from prof sample set. */
|
if (config_stats || (config_prof && opt_prof))
|
||||||
if (config_prof && opt_prof) {
|
|
||||||
size_t usize;
|
|
||||||
|
|
||||||
usize = isalloc(tsd, ptr, config_prof);
|
usize = isalloc(tsd, ptr, config_prof);
|
||||||
|
/* Remove huge allocation from prof sample set. */
|
||||||
|
if (config_prof && opt_prof)
|
||||||
prof_free(tsd, ptr, usize);
|
prof_free(tsd, ptr, usize);
|
||||||
}
|
|
||||||
huge_dalloc(tsd, ptr);
|
huge_dalloc(tsd, ptr);
|
||||||
malloc_mutex_lock(tsd, &arena->huge_mtx);
|
malloc_mutex_lock(tsd, &arena->huge_mtx);
|
||||||
|
/* Cancel out unwanted effects on stats. */
|
||||||
|
if (config_stats)
|
||||||
|
arena_huge_reset_stats_cancel(arena, usize);
|
||||||
}
|
}
|
||||||
malloc_mutex_unlock(tsd, &arena->huge_mtx);
|
malloc_mutex_unlock(tsd, &arena->huge_mtx);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user