fix: lock tracking

master
Sean McBride 2 years ago
parent 34e8731854
commit cce8c1981e

@ -5,6 +5,7 @@
extern thread_local uint64_t generic_thread_lock_duration;
extern thread_local uint64_t generic_thread_lock_longest;
extern thread_local const char *generic_thread_lock_longest_fn;
extern thread_local uint64_t generic_thread_start_timestamp;
void generic_thread_dump_lock_overhead(void);

@ -32,12 +32,7 @@ typedef ck_spinlock_mcs_t lock_t;
#define LOCK_LOCK_WITH_BOOKKEEPING(lock, unique_variable_name) \
struct ck_spinlock_mcs _hygiene_##unique_variable_name##_node; \
uint64_t _hygiene_##unique_variable_name##_pre = __getcycles(); \
ck_spinlock_mcs_lock((lock), &(_hygiene_##unique_variable_name##_node)); \
uint64_t _hygiene_##unique_variable_name##_duration = (__getcycles() - _hygiene_##unique_variable_name##_pre); \
if (_hygiene_##unique_variable_name##_duration > generic_thread_lock_longest) { \
generic_thread_lock_longest = _hygiene_##unique_variable_name##_duration; \
} \
generic_thread_lock_duration += _hygiene_##unique_variable_name##_duration;
ck_spinlock_mcs_lock((lock), &(_hygiene_##unique_variable_name##_node));
/**
* Unlocks a lock
@ -45,7 +40,13 @@ typedef ck_spinlock_mcs_t lock_t;
* @param unique_variable_name - a unique prefix to hygienically namespace an associated lock/unlock pair
*/
#define LOCK_UNLOCK_WITH_BOOKKEEPING(lock, unique_variable_name) \
ck_spinlock_mcs_unlock(lock, &(_hygiene_##unique_variable_name##_node));
ck_spinlock_mcs_unlock(lock, &(_hygiene_##unique_variable_name##_node)); \
uint64_t _hygiene_##unique_variable_name##_duration = (__getcycles() - _hygiene_##unique_variable_name##_pre); \
if (_hygiene_##unique_variable_name##_duration > generic_thread_lock_longest) { \
generic_thread_lock_longest = _hygiene_##unique_variable_name##_duration; \
generic_thread_lock_longest_fn = __func__; \
} \
generic_thread_lock_duration += _hygiene_##unique_variable_name##_duration;
/**
* Locks a lock, keeping track of overhead

@ -12,6 +12,7 @@ extern uint32_t runtime_quantum_us;
thread_local uint64_t generic_thread_lock_duration = 0;
thread_local uint64_t generic_thread_lock_longest = 0;
thread_local uint64_t generic_thread_start_timestamp = 0;
thread_local const char *generic_thread_lock_longest_fn = NULL;
void
generic_thread_initialize()

Loading…
Cancel
Save