Add stats for stashed bytes in tcache.
This commit is contained in:
15
src/arena.c
15
src/arena.c
@@ -148,18 +148,21 @@ arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
|
||||
|
||||
LOCKEDINT_MTX_UNLOCK(tsdn, arena->stats.mtx);
|
||||
|
||||
/* tcache_bytes counts currently cached bytes. */
|
||||
/* Currently cached bytes and sanitizer-stashed bytes in tcache. */
|
||||
astats->tcache_bytes = 0;
|
||||
astats->tcache_stashed_bytes = 0;
|
||||
malloc_mutex_lock(tsdn, &arena->tcache_ql_mtx);
|
||||
cache_bin_array_descriptor_t *descriptor;
|
||||
ql_foreach(descriptor, &arena->cache_bin_array_descriptor_ql, link) {
|
||||
for (szind_t i = 0; i < nhbins; i++) {
|
||||
cache_bin_t *cache_bin = &descriptor->bins[i];
|
||||
astats->tcache_bytes +=
|
||||
cache_bin_ncached_get_remote(cache_bin,
|
||||
&tcache_bin_info[i]) * sz_index2size(i) +
|
||||
cache_bin_nstashed_get(cache_bin,
|
||||
&tcache_bin_info[i]) * sz_index2size(i);
|
||||
cache_bin_sz_t ncached, nstashed;
|
||||
cache_bin_nitems_get_remote(cache_bin,
|
||||
&tcache_bin_info[i], &ncached, &nstashed);
|
||||
|
||||
astats->tcache_bytes += ncached * sz_index2size(i);
|
||||
astats->tcache_stashed_bytes += nstashed *
|
||||
sz_index2size(i);
|
||||
}
|
||||
}
|
||||
malloc_mutex_prof_read(tsdn,
|
||||
|
@@ -290,6 +290,7 @@ CTL_PROTO(stats_arenas_i_base)
|
||||
CTL_PROTO(stats_arenas_i_internal)
|
||||
CTL_PROTO(stats_arenas_i_metadata_thp)
|
||||
CTL_PROTO(stats_arenas_i_tcache_bytes)
|
||||
CTL_PROTO(stats_arenas_i_tcache_stashed_bytes)
|
||||
CTL_PROTO(stats_arenas_i_resident)
|
||||
CTL_PROTO(stats_arenas_i_abandoned_vm)
|
||||
CTL_PROTO(stats_arenas_i_hpa_sec_bytes)
|
||||
@@ -787,6 +788,8 @@ static const ctl_named_node_t stats_arenas_i_node[] = {
|
||||
{NAME("internal"), CTL(stats_arenas_i_internal)},
|
||||
{NAME("metadata_thp"), CTL(stats_arenas_i_metadata_thp)},
|
||||
{NAME("tcache_bytes"), CTL(stats_arenas_i_tcache_bytes)},
|
||||
{NAME("tcache_stashed_bytes"),
|
||||
CTL(stats_arenas_i_tcache_stashed_bytes)},
|
||||
{NAME("resident"), CTL(stats_arenas_i_resident)},
|
||||
{NAME("abandoned_vm"), CTL(stats_arenas_i_abandoned_vm)},
|
||||
{NAME("hpa_sec_bytes"), CTL(stats_arenas_i_hpa_sec_bytes)},
|
||||
@@ -1169,6 +1172,8 @@ MUTEX_PROF_ARENA_MUTEXES
|
||||
&astats->astats.pa_shard_stats.pac_stats.abandoned_vm);
|
||||
|
||||
sdstats->astats.tcache_bytes += astats->astats.tcache_bytes;
|
||||
sdstats->astats.tcache_stashed_bytes +=
|
||||
astats->astats.tcache_stashed_bytes;
|
||||
|
||||
if (ctl_arena->arena_ind == 0) {
|
||||
sdstats->astats.uptime = astats->astats.uptime;
|
||||
@@ -3503,6 +3508,8 @@ CTL_RO_CGEN(config_stats, stats_arenas_i_metadata_thp,
|
||||
arenas_i(mib[2])->astats->astats.metadata_thp, size_t)
|
||||
CTL_RO_CGEN(config_stats, stats_arenas_i_tcache_bytes,
|
||||
arenas_i(mib[2])->astats->astats.tcache_bytes, size_t)
|
||||
CTL_RO_CGEN(config_stats, stats_arenas_i_tcache_stashed_bytes,
|
||||
arenas_i(mib[2])->astats->astats.tcache_stashed_bytes, size_t)
|
||||
CTL_RO_CGEN(config_stats, stats_arenas_i_resident,
|
||||
arenas_i(mib[2])->astats->astats.resident,
|
||||
size_t)
|
||||
|
@@ -1055,7 +1055,7 @@ stats_arena_print(emitter_t *emitter, unsigned i, bool bins, bool large,
|
||||
size_t large_allocated;
|
||||
uint64_t large_nmalloc, large_ndalloc, large_nrequests, large_nfills,
|
||||
large_nflushes;
|
||||
size_t tcache_bytes, abandoned_vm;
|
||||
size_t tcache_bytes, tcache_stashed_bytes, abandoned_vm;
|
||||
uint64_t uptime;
|
||||
|
||||
CTL_GET("arenas.page", &page, size_t);
|
||||
@@ -1344,6 +1344,7 @@ stats_arena_print(emitter_t *emitter, unsigned i, bool bins, bool large,
|
||||
GET_AND_EMIT_MEM_STAT(internal)
|
||||
GET_AND_EMIT_MEM_STAT(metadata_thp)
|
||||
GET_AND_EMIT_MEM_STAT(tcache_bytes)
|
||||
GET_AND_EMIT_MEM_STAT(tcache_stashed_bytes)
|
||||
GET_AND_EMIT_MEM_STAT(resident)
|
||||
GET_AND_EMIT_MEM_STAT(abandoned_vm)
|
||||
GET_AND_EMIT_MEM_STAT(extent_avail)
|
||||
|
@@ -553,7 +553,7 @@ tcache_bin_flush_stashed(tsd_t *tsd, tcache_t *tcache, cache_bin_t *cache_bin,
|
||||
cache_bin_sz_t orig_cached = cache_bin_ncached_get_local(cache_bin,
|
||||
info);
|
||||
|
||||
cache_bin_sz_t nstashed = cache_bin_nstashed_get(cache_bin, info);
|
||||
cache_bin_sz_t nstashed = cache_bin_nstashed_get_local(cache_bin, info);
|
||||
assert(orig_cached + nstashed <= cache_bin_info_ncached_max(info));
|
||||
if (nstashed == 0) {
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ tcache_bin_flush_stashed(tsd_t *tsd, tcache_t *tcache, cache_bin_t *cache_bin,
|
||||
is_small);
|
||||
cache_bin_finish_flush_stashed(cache_bin, info);
|
||||
|
||||
assert(cache_bin_nstashed_get(cache_bin, info) == 0);
|
||||
assert(cache_bin_nstashed_get_local(cache_bin, info) == 0);
|
||||
assert(cache_bin_ncached_get_local(cache_bin, info) == orig_cached);
|
||||
assert(head_content == *cache_bin->stack_head);
|
||||
}
|
||||
|
Reference in New Issue
Block a user