-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: Add async data cache lock contention stats #16203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
|
@kewang1024 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D92068037. |
…6203) Summary: New metrics added to monitor time spent waiting for shard mutexes: - `kMetricMemoryCacheNumShardMutexWaitClocks`: Total clocks waiting for shard mutexes. - `kMetricMemoryCacheShardMutexWaitTimeMs`: Milliseconds waited, based on ~3GHz CPU. Differential Revision: D92068037
95ea4c7 to
fd8bda8
Compare
xiaoxmeng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kewang1024 thanks for the change. Left some comments. Do we really need to count these stats?
|
|
||
| // Clocks spent waiting to acquire shard mutexes, since last counter retrieval | ||
| DEFINE_METRIC( | ||
| kMetricMemoryCacheNumShardMutexWaitClocks, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update metrics.rst for the new metrics?
| kMetricMemoryCacheNumShardMutexWaitClocks, | ||
| facebook::velox::StatType::SUM); | ||
|
|
||
| // Time in milliseconds spent waiting to acquire shard mutexes, since last |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think walltime is sufficient.
s/kMetricMemoryCacheShardMutexWaitTimeMs/kMetricMemoryCacheLockWaitTimeUs/?
| std::atomic<uint64_t> allocClocks_{0}; | ||
| // Tracker of cumulative clocks spent waiting to acquire shard mutex. | ||
| // Mutable to allow updating from const methods like exists(). | ||
| mutable std::atomic<uint64_t> shardMutexWaitClocks_{0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::atomic_uint64_t shardLockWaitUs_
| /// lifetime for entries in cache. | ||
| int64_t sumEvictScore{0}; | ||
| /// Cumulative clocks spent waiting to acquire shard mutexes. | ||
| uint64_t shardMutexWaitClocks{0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/shardMutexWaitClocks/shardLockWaitUs/
| public: | ||
| TimedLockGuard(std::mutex& mutex, std::atomic<uint64_t>& waitClocks) | ||
| : lock_(mutex, std::defer_lock) { | ||
| ClockTimer timer(waitClocks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use NanosecondTimer?
| // Helper that uses ClockTimer to measure the lock acquisition time. | ||
| class TimedLockGuard { | ||
| public: | ||
| TimedLockGuard(std::mutex& mutex, std::atomic<uint64_t>& waitClocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have a per-thread local counter for this? Like use ConcurrentCounter in velox/common/base/ConcurrentCounter.h?
Summary:
New metrics added to monitor time spent waiting for shard mutexes:
kMetricMemoryCacheNumShardMutexWaitClocks: Total clocks waiting for shard mutexes.kMetricMemoryCacheShardMutexWaitTimeMs: Milliseconds waited, based on ~3GHz CPU.Differential Revision: D92068037