Add arena lock stats output.

This commit is contained in:
Qi Wang
2017-03-10 12:14:05 -08:00
committed by Qi Wang
parent a4f176af57
commit 0fb5c0e853
9 changed files with 269 additions and 51 deletions

View File

@@ -1,6 +1,14 @@
#ifndef JEMALLOC_INTERNAL_CTL_EXTERNS_H
#define JEMALLOC_INTERNAL_CTL_EXTERNS_H
/* Maximum ctl tree depth. */
#define CTL_MAX_DEPTH 7
#define NUM_ARENA_PROF_LOCKS 6
#define NUM_LOCK_PROF_COUNTERS 7
const char *arena_lock_names[NUM_ARENA_PROF_LOCKS];
const char *lock_counter_names[NUM_LOCK_PROF_COUNTERS];
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
void *newp, size_t newlen);
int ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp,

View File

@@ -29,9 +29,9 @@ malloc_mutex_trylock(malloc_mutex_t *mutex) {
/* Aggregate lock prof data. */
JEMALLOC_INLINE void
malloc_lock_prof_merge(lock_prof_data_t *sum, lock_prof_data_t *data) {
nstime_add(&sum->tot_wait_time, &data->tot_wait_time);
if (nstime_compare(&data->max_wait_time, &sum->max_wait_time)) {
nstime_copy(&sum->max_wait_time, &data->max_wait_time);
sum->tot_wait_time += data->tot_wait_time;
if (data->max_wait_time > sum->max_wait_time) {
sum->max_wait_time = data->max_wait_time;
}
sum->n_wait_times += data->n_wait_times;
sum->n_spin_acquired += data->n_spin_acquired;

View File

@@ -6,10 +6,10 @@ struct lock_prof_data_s {
* Counters touched on the slow path, i.e. when there is lock
* contention. We update them once we have the lock.
*/
/* Total time spent waiting on this lock. */
nstime_t tot_wait_time;
/* Max time spent on a single lock operation. */
nstime_t max_wait_time;
/* Total time (in nano seconds) spent waiting on this lock. */
uint64_t tot_wait_time;
/* Max time (in nano seconds) spent on a single lock operation. */
uint64_t max_wait_time;
/* # of times have to wait for this lock (after spinning). */
uint64_t n_wait_times;
/* # of times acquired the lock through local spinning. */

View File

@@ -28,8 +28,7 @@ typedef struct malloc_mutex_s malloc_mutex_t;
# define MALLOC_MUTEX_TRYLOCK(m) (pthread_mutex_trylock(&(m)->lock) != 0)
#endif
#define LOCK_PROF_DATA_INITIALIZER \
{NSTIME_ZERO_INITIALIZER, NSTIME_ZERO_INITIALIZER, 0, 0, 0, 0, 0, NULL, 0}
#define LOCK_PROF_DATA_INITIALIZER {0, 0, 0, 0, 0, 0, 0, NULL, 0}
#ifdef _WIN32
# define MALLOC_MUTEX_INITIALIZER

View File

@@ -124,6 +124,13 @@ struct arena_stats_s {
/* Number of bytes cached in tcache associated with this arena. */
atomic_zu_t tcache_bytes; /* Derived. */
lock_prof_data_t large_mtx_data;
lock_prof_data_t extent_freelist_mtx_data;
lock_prof_data_t extents_cached_mtx_data;
lock_prof_data_t extents_retained_mtx_data;
lock_prof_data_t decay_mtx_data;
lock_prof_data_t tcache_mtx_data;
/* One element for each large size class. */
malloc_large_stats_t lstats[NSIZES - NBINS];
};