mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Implement opt.stats_interval and the _opts options.
Add options stats_interval and stats_interval_opts to allow interval based stats printing. This provides an easy way to collect stats without code changes, because opt.stats_print may not work (some binaries never exit).
This commit is contained in:
@@ -25,6 +25,7 @@ static void thread_##event##_event_handler(tsd_t *tsd);
|
||||
ITERATE_OVER_ALL_EVENTS
|
||||
#undef E
|
||||
|
||||
/* (Re)Init functions. */
|
||||
static void
|
||||
tsd_thread_tcache_gc_event_init(tsd_t *tsd) {
|
||||
assert(TCACHE_GC_INCR_BYTES > 0);
|
||||
@@ -37,11 +38,19 @@ tsd_thread_prof_sample_event_init(tsd_t *tsd) {
|
||||
prof_sample_threshold_update(tsd);
|
||||
}
|
||||
|
||||
static void
|
||||
tsd_thread_stats_interval_event_init(tsd_t *tsd) {
|
||||
assert(opt_stats_interval >= 0);
|
||||
uint64_t interval = stats_interval_accum_batch_size();
|
||||
thread_stats_interval_event_update(tsd, interval);
|
||||
}
|
||||
|
||||
/* Handler functions. */
|
||||
static void
|
||||
thread_tcache_gc_event_handler(tsd_t *tsd) {
|
||||
assert(TCACHE_GC_INCR_BYTES > 0);
|
||||
assert(tcache_gc_event_wait_get(tsd) == 0U);
|
||||
thread_tcache_gc_event_update(tsd, TCACHE_GC_INCR_BYTES);
|
||||
tsd_thread_tcache_gc_event_init(tsd);
|
||||
tcache_t *tcache = tcache_get(tsd);
|
||||
if (tcache != NULL) {
|
||||
tcache_event_hard(tsd, tcache);
|
||||
@@ -71,6 +80,21 @@ thread_prof_sample_event_handler(tsd_t *tsd) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
thread_stats_interval_event_handler(tsd_t *tsd) {
|
||||
assert(opt_stats_interval >= 0);
|
||||
assert(stats_interval_event_wait_get(tsd) == 0U);
|
||||
uint64_t last_event = thread_allocated_last_event_get(tsd);
|
||||
uint64_t last_stats_event = stats_interval_last_event_get(tsd);
|
||||
stats_interval_last_event_set(tsd, last_event);
|
||||
|
||||
if (stats_interval_accum(tsd, last_event - last_stats_event)) {
|
||||
je_malloc_stats_print(NULL, NULL, opt_stats_interval_opts);
|
||||
}
|
||||
tsd_thread_stats_interval_event_init(tsd);
|
||||
}
|
||||
/* Per event facilities done. */
|
||||
|
||||
static uint64_t
|
||||
thread_allocated_next_event_compute(tsd_t *tsd) {
|
||||
uint64_t wait = THREAD_EVENT_MAX_START_WAIT;
|
||||
|
||||
Reference in New Issue
Block a user