From 8be558449446a5190bdf661da428ecd6b9fb2a8f Mon Sep 17 00:00:00 2001 From: Yinan Zhang Date: Wed, 15 Apr 2020 12:21:38 -0700 Subject: [PATCH] Initialize prof idump counter once rather than once per arena --- include/jemalloc/internal/prof_externs.h | 1 - src/arena.c | 6 ------ src/prof.c | 8 ++++++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/jemalloc/internal/prof_externs.h b/include/jemalloc/internal/prof_externs.h index 8c657c63..0fbd3eae 100644 --- a/include/jemalloc/internal/prof_externs.h +++ b/include/jemalloc/internal/prof_externs.h @@ -74,7 +74,6 @@ void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs, #endif int prof_getpid(void); void prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind); -bool prof_accum_init(void); bool prof_idump_accum(tsdn_t *tsdn, uint64_t accumbytes); void prof_idump(tsdn_t *tsdn); bool prof_mdump(tsd_t *tsd, const char *filename); diff --git a/src/arena.c b/src/arena.c index 12c6b0a8..b61d373b 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1463,12 +1463,6 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) { } } - if (config_prof) { - if (prof_accum_init()) { - goto label_error; - } - } - atomic_store_u(&arena->dss_prec, (unsigned)extent_dss_prec_get(), ATOMIC_RELAXED); diff --git a/src/prof.c b/src/prof.c index ff09a5d7..cb71850f 100644 --- a/src/prof.c +++ b/src/prof.c @@ -641,8 +641,8 @@ prof_fdump(void) { prof_dump(tsd, false, filename, opt_prof_leak); } -bool -prof_accum_init(void) { +static bool +prof_idump_accum_init(void) { cassert(config_prof); return counter_accum_init(&prof_idump_accumulated, prof_interval); @@ -1021,6 +1021,10 @@ prof_boot2(tsd_t *tsd, base_t *base) { return true; } + if (prof_idump_accum_init()) { + return true; + } + if (malloc_mutex_init(&prof_dump_filename_mtx, "prof_dump_filename", WITNESS_RANK_PROF_DUMP_FILENAME, malloc_mutex_rank_exclusive)) { return true;