Add profiling for the background thread mutex.
This commit is contained in:
parent
2bee0c6251
commit
5f5ed2198e
@ -10,12 +10,12 @@ extern bool isthreaded;
|
||||
# define isthreaded true
|
||||
#endif
|
||||
|
||||
bool malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
|
||||
bool malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
|
||||
witness_rank_t rank, malloc_mutex_lock_order_t lock_order);
|
||||
void malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_parent(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
bool malloc_mutex_boot(void);
|
||||
void malloc_mutex_prof_data_reset(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
void malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_parent(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
void malloc_mutex_postfork_child(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
bool malloc_mutex_boot(void);
|
||||
void malloc_mutex_prof_data_reset(tsdn_t *tsdn, malloc_mutex_t *mutex);
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_MUTEX_EXTERNS_H */
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "jemalloc/internal/tsd_types.h"
|
||||
|
||||
#define MUTEX_PROF_GLOBAL_MUTEXES \
|
||||
OP(background_thread) \
|
||||
OP(ctl) \
|
||||
OP(prof)
|
||||
|
||||
|
12
src/ctl.c
12
src/ctl.c
@ -947,6 +947,15 @@ ctl_refresh(tsdn_t *tsdn) {
|
||||
READ_GLOBAL_MUTEX_PROF_DATA(global_prof_mutex_prof,
|
||||
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. */
|
||||
malloc_mutex_prof_read(tsdn,
|
||||
&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. */
|
||||
MUTEX_PROF_RESET(ctl_mtx);
|
||||
if (have_background_thread) {
|
||||
MUTEX_PROF_RESET(background_thread_lock);
|
||||
}
|
||||
if (config_prof && opt_prof) {
|
||||
MUTEX_PROF_RESET(bt2gctx_mtx);
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ label_spin_done:
|
||||
static void
|
||||
mutex_prof_data_init(mutex_prof_data_t *data) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user