Switch to nstime_t for the time related fields in mutex profiling.

This commit is contained in:
Qi Wang
2017-03-17 17:42:10 -07:00
committed by Qi Wang
parent 74f78cafda
commit f6698ec1e6
5 changed files with 25 additions and 21 deletions

View File

@@ -29,10 +29,11 @@ malloc_mutex_trylock(malloc_mutex_t *mutex) {
/* Aggregate lock prof data. */
JEMALLOC_INLINE void
malloc_mutex_prof_merge(mutex_prof_data_t *sum, mutex_prof_data_t *data) {
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;
nstime_add(&sum->tot_wait_time, &data->tot_wait_time);
if (nstime_compare(&sum->max_wait_time, &data->max_wait_time) < 0) {
nstime_copy(&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

@@ -7,9 +7,9 @@ struct mutex_prof_data_s {
* contention. We update them once we have the lock.
*/
/* Total time (in nano seconds) spent waiting on this mutex. */
uint64_t tot_wait_time;
nstime_t tot_wait_time;
/* Max time (in nano seconds) spent on a single lock operation. */
uint64_t max_wait_time;
nstime_t max_wait_time;
/* # of times have to wait for this mutex (after spinning). */
uint64_t n_wait_times;
/* # of times acquired the mutex through local spinning. */

View File

@@ -34,7 +34,8 @@ 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 {0, 0, 0, 0, 0, 0, 0, NULL, 0}
#define LOCK_PROF_DATA_INITIALIZER \
{NSTIME_ZERO_INITIALIZER, NSTIME_ZERO_INITIALIZER, 0, 0, 0, 0, 0, NULL, 0}
#ifdef _WIN32
# define MALLOC_MUTEX_INITIALIZER