diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2013-08-06 17:09:30 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2013-08-09 12:45:36 -0700 |
commit | 1afde13b36cc1d67528104c2b1395495f669cd3f (patch) | |
tree | 5bcf953cb76033d812f06c096908344e8b6e9cd9 /runtime/base/mutex-inl.h | |
parent | c9f9444a0d58f395fee5ddd9f55ff32f92cb7b57 (diff) | |
download | art-1afde13b36cc1d67528104c2b1395495f669cd3f.zip art-1afde13b36cc1d67528104c2b1395495f669cd3f.tar.gz art-1afde13b36cc1d67528104c2b1395495f669cd3f.tar.bz2 |
Polish the lock contention logging.
- Make the code compilable.
- Surround the code with kLogLockContentions instead of #ifdef CONTENTION_LOGGING.
- Dump contended locks before never-contended locks for better log readability.
- Change the wait time unit from ms to us for better precision.
Bug: 9986464
Change-Id: I121c6ccf4424d3e0339b0dcd25e18976b41fe4f3
Diffstat (limited to 'runtime/base/mutex-inl.h')
-rw-r--r-- | runtime/base/mutex-inl.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index 1337dff..7f3b459 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -40,29 +40,25 @@ static inline int futex(volatile int *uaddr, int op, int val, const struct times class ScopedContentionRecorder { public: -#if CONTENTION_LOGGING - ScopedContentionRecorder(BaseMutex* mutex, uint64_t blocked_tid, uint64_t owner_tid) : - mutex_(mutex), blocked_tid_(blocked_tid), owner_tid_(owner_tid), - start_milli_time_(MilliTime()) { + ScopedContentionRecorder(BaseMutex* mutex, uint64_t blocked_tid, uint64_t owner_tid) + : mutex_(kLogLockContentions ? mutex : NULL), + blocked_tid_(kLogLockContentions ? blocked_tid : 0), + owner_tid_(kLogLockContentions ? owner_tid : 0), + start_nano_time_(kLogLockContentions ? NanoTime() : 0) { } -#else - ScopedContentionRecorder(BaseMutex*, uint64_t, uint64_t) {} -#endif ~ScopedContentionRecorder() { -#if CONTENTION_LOGGING - uint64_t end_milli_time = MilliTime(); - mutex_->RecordContention(blocked_tid_, owner_tid_, end_milli_time - start_milli_time_); -#endif + if (kLogLockContentions) { + uint64_t end_nano_time = NanoTime(); + mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_); + } } private: -#if CONTENTION_LOGGING BaseMutex* const mutex_; const uint64_t blocked_tid_; const uint64_t owner_tid_; - const uint64_t start_milli_time_; -#endif + const uint64_t start_nano_time_; }; static inline uint64_t SafeGetTid(const Thread* self) { |