Add profiling for the background thread mutex.

This commit is contained in:
Qi Wang 2017-05-12 16:26:59 -07:00 committed by Qi Wang
parent 2bee0c6251
commit 5f5ed2198e
4 changed files with 21 additions and 6 deletions

View File

@ -6,6 +6,7 @@
#include "jemalloc/internal/tsd_types.h" #include "jemalloc/internal/tsd_types.h"
#define MUTEX_PROF_GLOBAL_MUTEXES \ #define MUTEX_PROF_GLOBAL_MUTEXES \
OP(background_thread) \
OP(ctl) \ OP(ctl) \
OP(prof) OP(prof)

View File

@ -947,6 +947,15 @@ ctl_refresh(tsdn_t *tsdn) {
READ_GLOBAL_MUTEX_PROF_DATA(global_prof_mutex_prof, READ_GLOBAL_MUTEX_PROF_DATA(global_prof_mutex_prof,
bt2gctx_mtx); bt2gctx_mtx);
} }
if (have_background_thread) {
READ_GLOBAL_MUTEX_PROF_DATA(
global_prof_mutex_background_thread,
background_thread_lock);
} else {
memset(&ctl_stats->mutex_prof_data[
global_prof_mutex_background_thread], 0,
sizeof(mutex_prof_data_t));
}
/* We own ctl mutex already. */ /* We own ctl mutex already. */
malloc_mutex_prof_read(tsdn, malloc_mutex_prof_read(tsdn,
&ctl_stats->mutex_prof_data[global_prof_mutex_ctl], &ctl_stats->mutex_prof_data[global_prof_mutex_ctl],
@ -2557,6 +2566,9 @@ stats_mutexes_reset_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
/* Global mutexes: ctl and prof. */ /* Global mutexes: ctl and prof. */
MUTEX_PROF_RESET(ctl_mtx); MUTEX_PROF_RESET(ctl_mtx);
if (have_background_thread) {
MUTEX_PROF_RESET(background_thread_lock);
}
if (config_prof && opt_prof) { if (config_prof && opt_prof) {
MUTEX_PROF_RESET(bt2gctx_mtx); MUTEX_PROF_RESET(bt2gctx_mtx);
} }

View File

@ -112,6 +112,8 @@ label_spin_done:
static void static void
mutex_prof_data_init(mutex_prof_data_t *data) { mutex_prof_data_init(mutex_prof_data_t *data) {
memset(data, 0, sizeof(mutex_prof_data_t)); memset(data, 0, sizeof(mutex_prof_data_t));
nstime_init(&data->max_wait_time, 0);
nstime_init(&data->tot_wait_time, 0);
data->prev_owner = NULL; data->prev_owner = NULL;
} }