32 #include "mongo/platform/atomic_word.h" 43 static int64_t
get(
const int64_t& counter) {
47 static int64_t
get(
const AtomicInt64& counter) {
48 return counter.load();
51 static void set(int64_t& counter, int64_t value) {
55 static void set(AtomicInt64& counter, int64_t value) {
59 static void add(int64_t& counter, int64_t value) {
63 static void add(int64_t& counter,
const AtomicInt64& value) {
64 counter += value.load();
67 static void add(AtomicInt64& counter, int64_t value) {
68 counter.addAndFetch(value);
76 template <
typename CounterType>
78 template <
typename OtherType>
105 template <
typename CounterType>
134 return _oplogStats.modeStats[mode];
137 return _stats[resId.getType()].modeStats[mode];
140 template <
typename OtherType>
147 const OtherLockStatCountersType& otherStats = other.
_stats[i].modeStats[mode];
148 LockStatCountersType& thisStats = _stats[i].modeStats[mode];
149 thisStats.
append(otherStats);
155 const OtherLockStatCountersType& otherStats = other.
_oplogStats.modeStats[mode];
156 LockStatCountersType& thisStats = _oplogStats.modeStats[mode];
157 thisStats.
append(otherStats);
161 void report(BSONObjBuilder* builder)
const;
167 template <
typename T>
178 void _report(BSONObjBuilder* builder,
179 const char* sectionName,
Templatized lock statistics management class, which can be specialized with atomic integers for the g...
Definition: lock_stats.h:106
static void add(AtomicInt64 &counter, int64_t value)
Definition: lock_stats.h:67
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
LockStatCounters< CounterType > LockStatCountersType
Definition: lock_stats.h:109
static void set(int64_t &counter, int64_t value)
Definition: lock_stats.h:51
const ResourceId resourceIdOplog
Definition: lock_state.cpp:1108
PerModeLockStatCounters _stats[ResourceTypesCount]
Definition: lock_stats.h:185
Uniquely identifies a lockable resource.
Definition: lock_manager_defs.h:176
Definition: lock_manager_defs.h:165
void resetGlobalLockStats()
Currently used for testing only.
Definition: lock_state.cpp:1096
void append(const LockStatCounters< OtherType > &other)
Definition: lock_stats.h:79
LockMode
Lock modes.
Definition: lock_manager_defs.h:59
Bundle of locking statistics values.
Definition: lock_stats.h:77
PerModeLockStatCounters _oplogStats
Definition: lock_stats.h:186
CounterType numDeadlocks
Definition: lock_stats.h:97
void recordDeadlock(ResourceId resId, LockMode mode)
Definition: lock_stats.h:128
CounterType combinedWaitTimeMicros
Definition: lock_stats.h:96
void recordWaitTime(ResourceId resId, LockMode mode, int64_t waitMicros)
Definition: lock_stats.h:124
Operations for manipulating the lock statistics abstracting whether they are atomic or not...
Definition: lock_stats.h:42
void reportGlobalLockingStats(SingleThreadedLockStats *outStats)
Reports instance-wide locking statistics, which can then be converted to BSON or logged.
Definition: lock_state.cpp:1092
static void add(int64_t &counter, int64_t value)
Definition: lock_stats.h:59
Definition: lock_manager_defs.h:68
void reset()
Definition: lock_stats.h:86
LockStats< int64_t > SingleThreadedLockStats
Definition: lock_stats.h:189
Definition: lock_stats.h:173
void append(const LockStats< OtherType > &other)
Definition: lock_stats.h:141
CounterType numWaits
Definition: lock_stats.h:95
static void add(int64_t &counter, const AtomicInt64 &value)
Definition: lock_stats.h:63
LockStats< AtomicInt64 > AtomicLockStats
Definition: lock_stats.h:190
void recordAcquisition(ResourceId resId, LockMode mode)
Definition: lock_stats.h:116
void recordWait(ResourceId resId, LockMode mode)
Definition: lock_stats.h:120
CounterType numAcquisitions
Definition: lock_stats.h:94