summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/lock_stats.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/concurrency/lock_stats.h')
-rw-r--r--src/mongo/db/concurrency/lock_stats.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mongo/db/concurrency/lock_stats.h b/src/mongo/db/concurrency/lock_stats.h
index d45b3b38864..69855480393 100644
--- a/src/mongo/db/concurrency/lock_stats.h
+++ b/src/mongo/db/concurrency/lock_stats.h
@@ -141,6 +141,10 @@ public:
return _oplogStats.modeStats[mode];
}
+ if (resId.getType() == RESOURCE_GLOBAL) {
+ return _resourceGlobalStats[resId.getHashId()].modeStats[mode];
+ }
+
return _stats[resId.getType()].modeStats[mode];
}
@@ -148,7 +152,15 @@ public:
void append(const LockStats<OtherType>& other) {
typedef LockStatCounters<OtherType> OtherLockStatCountersType;
- // Append all lock stats
+ // Append global lock stats.
+ for (uint8_t i = 0; i < static_cast<uint8_t>(ResourceGlobalId::kNumIds); ++i) {
+ for (uint8_t mode = 0; mode < LockModesCount; ++mode) {
+ _resourceGlobalStats[i].modeStats[mode].append(
+ other._resourceGlobalStats[i].modeStats[mode]);
+ }
+ }
+
+ // Append all non-global, non-oplog lock stats.
for (int i = 0; i < ResourceTypesCount; i++) {
for (int mode = 0; mode < LockModesCount; mode++) {
const OtherLockStatCountersType& otherStats = other._stats[i].modeStats[mode];
@@ -169,6 +181,13 @@ public:
void subtract(const LockStats<OtherType>& other) {
typedef LockStatCounters<OtherType> OtherLockStatCountersType;
+ for (uint8_t i = 0; i < static_cast<uint8_t>(ResourceGlobalId::kNumIds); ++i) {
+ for (uint8_t mode = 0; mode < LockModesCount; ++mode) {
+ _resourceGlobalStats[i].modeStats[mode].subtract(
+ other._resourceGlobalStats[i].modeStats[mode]);
+ }
+ }
+
for (int i = 0; i < ResourceTypesCount; i++) {
for (int mode = 0; mode < LockModesCount; mode++) {
const OtherLockStatCountersType& otherStats = other._stats[i].modeStats[mode];
@@ -206,8 +225,10 @@ private:
const PerModeLockStatCounters& stat) const;
- // Split the lock stats per resource type. Special-case the oplog so we can collect more
- // detailed stats for it.
+ // For the global resource, split the lock stats per ID since each one should be reported
+ // separately. For the remaining resources, split the lock stats per resource type. Special-case
+ // the oplog so we can collect more detailed stats for it.
+ PerModeLockStatCounters _resourceGlobalStats[static_cast<uint8_t>(ResourceGlobalId::kNumIds)];
PerModeLockStatCounters _stats[ResourceTypesCount];
PerModeLockStatCounters _oplogStats;
};