Reduce footprint of bin_t.

Avoid storing mutex_prof_data_t in bin_t.  Added bin_stats_data_t which is used
for reporting bin stats.
This commit is contained in:
Qi Wang 2019-11-05 20:43:59 -08:00 committed by Qi Wang
parent cb1a1f4ada
commit 9a7ae3c97f
6 changed files with 54 additions and 57 deletions

View File

@ -25,7 +25,7 @@ void arena_basic_stats_merge(tsdn_t *tsdn, arena_t *arena,
void arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads, void arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms, const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms,
size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats, size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats,
bin_stats_t *bstats, arena_stats_large_t *lstats, bin_stats_data_t *bstats, arena_stats_large_t *lstats,
arena_stats_extents_t *estats); arena_stats_extents_t *estats);
void arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena, void arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, extent_t *extent); extent_hooks_t **r_extent_hooks, extent_t *extent);

View File

@ -61,19 +61,20 @@ void bin_postfork_child(tsdn_t *tsdn, bin_t *bin);
/* Stats. */ /* Stats. */
static inline void static inline void
bin_stats_merge(tsdn_t *tsdn, bin_stats_t *dst_bin_stats, bin_t *bin) { bin_stats_merge(tsdn_t *tsdn, bin_stats_data_t *dst_bin_stats, bin_t *bin) {
malloc_mutex_lock(tsdn, &bin->lock); malloc_mutex_lock(tsdn, &bin->lock);
malloc_mutex_prof_accum(tsdn, &dst_bin_stats->mutex_data, &bin->lock); malloc_mutex_prof_accum(tsdn, &dst_bin_stats->mutex_data, &bin->lock);
dst_bin_stats->nmalloc += bin->stats.nmalloc; bin_stats_t *stats = &dst_bin_stats->stats_data;
dst_bin_stats->ndalloc += bin->stats.ndalloc; stats->nmalloc += bin->stats.nmalloc;
dst_bin_stats->nrequests += bin->stats.nrequests; stats->ndalloc += bin->stats.ndalloc;
dst_bin_stats->curregs += bin->stats.curregs; stats->nrequests += bin->stats.nrequests;
dst_bin_stats->nfills += bin->stats.nfills; stats->curregs += bin->stats.curregs;
dst_bin_stats->nflushes += bin->stats.nflushes; stats->nfills += bin->stats.nfills;
dst_bin_stats->nslabs += bin->stats.nslabs; stats->nflushes += bin->stats.nflushes;
dst_bin_stats->reslabs += bin->stats.reslabs; stats->nslabs += bin->stats.nslabs;
dst_bin_stats->curslabs += bin->stats.curslabs; stats->reslabs += bin->stats.reslabs;
dst_bin_stats->nonfull_slabs += bin->stats.nonfull_slabs; stats->curslabs += bin->stats.curslabs;
stats->nonfull_slabs += bin->stats.nonfull_slabs;
malloc_mutex_unlock(tsdn, &bin->lock); malloc_mutex_unlock(tsdn, &bin->lock);
} }

View File

@ -47,8 +47,11 @@ struct bin_stats_s {
/* Current size of nonfull slabs heap in this bin. */ /* Current size of nonfull slabs heap in this bin. */
size_t nonfull_slabs; size_t nonfull_slabs;
mutex_prof_data_t mutex_data;
}; };
typedef struct bin_stats_data_s bin_stats_data_t;
struct bin_stats_data_s {
bin_stats_t stats_data;
mutex_prof_data_t mutex_data;
};
#endif /* JEMALLOC_INTERNAL_BIN_STATS_H */ #endif /* JEMALLOC_INTERNAL_BIN_STATS_H */

View File

@ -42,7 +42,7 @@ typedef struct ctl_arena_stats_s {
uint64_t nfills_small; uint64_t nfills_small;
uint64_t nflushes_small; uint64_t nflushes_small;
bin_stats_t bstats[SC_NBINS]; bin_stats_data_t bstats[SC_NBINS];
arena_stats_large_t lstats[SC_NSIZES - SC_NBINS]; arena_stats_large_t lstats[SC_NSIZES - SC_NBINS];
arena_stats_extents_t estats[SC_NPSIZES]; arena_stats_extents_t estats[SC_NPSIZES];
} ctl_arena_stats_t; } ctl_arena_stats_t;

View File

@ -83,7 +83,7 @@ void
arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads, arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms, const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms,
size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats, size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats,
bin_stats_t *bstats, arena_stats_large_t *lstats, bin_stats_data_t *bstats, arena_stats_large_t *lstats,
arena_stats_extents_t *estats) { arena_stats_extents_t *estats) {
cassert(config_stats); cassert(config_stats);

View File

@ -789,7 +789,7 @@ ctl_arena_clear(ctl_arena_t *ctl_arena) {
ctl_arena->astats->nfills_small = 0; ctl_arena->astats->nfills_small = 0;
ctl_arena->astats->nflushes_small = 0; ctl_arena->astats->nflushes_small = 0;
memset(ctl_arena->astats->bstats, 0, SC_NBINS * memset(ctl_arena->astats->bstats, 0, SC_NBINS *
sizeof(bin_stats_t)); sizeof(bin_stats_data_t));
memset(ctl_arena->astats->lstats, 0, (SC_NSIZES - SC_NBINS) * memset(ctl_arena->astats->lstats, 0, (SC_NSIZES - SC_NBINS) *
sizeof(arena_stats_large_t)); sizeof(arena_stats_large_t));
memset(ctl_arena->astats->estats, 0, SC_NPSIZES * memset(ctl_arena->astats->estats, 0, SC_NPSIZES *
@ -810,19 +810,15 @@ ctl_arena_stats_amerge(tsdn_t *tsdn, ctl_arena_t *ctl_arena, arena_t *arena) {
ctl_arena->astats->lstats, ctl_arena->astats->estats); ctl_arena->astats->lstats, ctl_arena->astats->estats);
for (i = 0; i < SC_NBINS; i++) { for (i = 0; i < SC_NBINS; i++) {
ctl_arena->astats->allocated_small += bin_stats_t *bstats =
ctl_arena->astats->bstats[i].curregs * &ctl_arena->astats->bstats[i].stats_data;
ctl_arena->astats->allocated_small += bstats->curregs *
sz_index2size(i); sz_index2size(i);
ctl_arena->astats->nmalloc_small += ctl_arena->astats->nmalloc_small += bstats->nmalloc;
ctl_arena->astats->bstats[i].nmalloc; ctl_arena->astats->ndalloc_small += bstats->ndalloc;
ctl_arena->astats->ndalloc_small += ctl_arena->astats->nrequests_small += bstats->nrequests;
ctl_arena->astats->bstats[i].ndalloc; ctl_arena->astats->nfills_small += bstats->nfills;
ctl_arena->astats->nrequests_small += ctl_arena->astats->nflushes_small += bstats->nflushes;
ctl_arena->astats->bstats[i].nrequests;
ctl_arena->astats->nfills_small +=
ctl_arena->astats->bstats[i].nfills;
ctl_arena->astats->nflushes_small +=
ctl_arena->astats->bstats[i].nflushes;
} }
} else { } else {
arena_basic_stats_merge(tsdn, arena, &ctl_arena->nthreads, arena_basic_stats_merge(tsdn, arena, &ctl_arena->nthreads,
@ -935,29 +931,26 @@ MUTEX_PROF_ARENA_MUTEXES
/* Merge bin stats. */ /* Merge bin stats. */
for (i = 0; i < SC_NBINS; i++) { for (i = 0; i < SC_NBINS; i++) {
sdstats->bstats[i].nmalloc += astats->bstats[i].nmalloc; bin_stats_t *bstats = &astats->bstats[i].stats_data;
sdstats->bstats[i].ndalloc += astats->bstats[i].ndalloc; bin_stats_t *merged = &sdstats->bstats[i].stats_data;
sdstats->bstats[i].nrequests += merged->nmalloc += bstats->nmalloc;
astats->bstats[i].nrequests; merged->ndalloc += bstats->ndalloc;
merged->nrequests += bstats->nrequests;
if (!destroyed) { if (!destroyed) {
sdstats->bstats[i].curregs += merged->curregs += bstats->curregs;
astats->bstats[i].curregs;
} else { } else {
assert(astats->bstats[i].curregs == 0); assert(bstats->curregs == 0);
} }
sdstats->bstats[i].nfills += astats->bstats[i].nfills; merged->nfills += bstats->nfills;
sdstats->bstats[i].nflushes += merged->nflushes += bstats->nflushes;
astats->bstats[i].nflushes; merged->nslabs += bstats->nslabs;
sdstats->bstats[i].nslabs += astats->bstats[i].nslabs; merged->reslabs += bstats->reslabs;
sdstats->bstats[i].reslabs += astats->bstats[i].reslabs;
if (!destroyed) { if (!destroyed) {
sdstats->bstats[i].curslabs += merged->curslabs += bstats->curslabs;
astats->bstats[i].curslabs; merged->nonfull_slabs += bstats->nonfull_slabs;
sdstats->bstats[i].nonfull_slabs +=
astats->bstats[i].nonfull_slabs;
} else { } else {
assert(astats->bstats[i].curslabs == 0); assert(bstats->curslabs == 0);
assert(astats->bstats[i].nonfull_slabs == 0); assert(bstats->nonfull_slabs == 0);
} }
malloc_mutex_prof_merge(&sdstats->bstats[i].mutex_data, malloc_mutex_prof_merge(&sdstats->bstats[i].mutex_data,
&astats->bstats[i].mutex_data); &astats->bstats[i].mutex_data);
@ -3035,25 +3028,25 @@ stats_mutexes_reset_ctl(tsd_t *tsd, const size_t *mib,
} }
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nmalloc, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nmalloc,
arenas_i(mib[2])->astats->bstats[mib[4]].nmalloc, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nmalloc, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_ndalloc, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_ndalloc,
arenas_i(mib[2])->astats->bstats[mib[4]].ndalloc, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.ndalloc, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nrequests, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nrequests,
arenas_i(mib[2])->astats->bstats[mib[4]].nrequests, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nrequests, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_curregs, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_curregs,
arenas_i(mib[2])->astats->bstats[mib[4]].curregs, size_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.curregs, size_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nfills, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nfills,
arenas_i(mib[2])->astats->bstats[mib[4]].nfills, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nfills, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nflushes, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nflushes,
arenas_i(mib[2])->astats->bstats[mib[4]].nflushes, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nflushes, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nslabs, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nslabs,
arenas_i(mib[2])->astats->bstats[mib[4]].nslabs, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nslabs, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nreslabs, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nreslabs,
arenas_i(mib[2])->astats->bstats[mib[4]].reslabs, uint64_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.reslabs, uint64_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_curslabs, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_curslabs,
arenas_i(mib[2])->astats->bstats[mib[4]].curslabs, size_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.curslabs, size_t)
CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nonfull_slabs, CTL_RO_CGEN(config_stats, stats_arenas_i_bins_j_nonfull_slabs,
arenas_i(mib[2])->astats->bstats[mib[4]].nonfull_slabs, size_t) arenas_i(mib[2])->astats->bstats[mib[4]].stats_data.nonfull_slabs, size_t)
static const ctl_named_node_t * static const ctl_named_node_t *
stats_arenas_i_bins_j_index(tsdn_t *tsdn, const size_t *mib, stats_arenas_i_bins_j_index(tsdn_t *tsdn, const size_t *mib,