Permalink
Browse files

SERVER-4328 continued work on lock reporting stats. take out mess i m…

…ade mpreviously
  • Loading branch information...
1 parent 4bac4b0 commit de4a9b97e601e12101a6077584099a8071f1b102 @dwight dwight committed Apr 13, 2012
Showing with 15 additions and 15 deletions.
  1. +5 −8 src/mongo/db/d_concurrency.cpp
  2. +10 −7 src/mongo/db/lockstat.h
@@ -38,14 +38,11 @@ namespace mongo {
public:
string name() const { return r.name; }
LockStat stats;
- WrapperForRWLock(const char *name) :
- r(name)
- {
- }
- void lock() { LockStat::Acquiring a(stats,'W'); r.lock(); }
- void lock_shared() { LockStat::Acquiring a(stats,'R'); r.lock_shared(); }
- void unlock() { stats.unlocking('W'); r.unlock(); }
- void unlock_shared() { stats.unlocking('R'); r.unlock_shared(); }
+ WrapperForRWLock(const char *name) : r(name) { }
+ void lock() { LockStat::Acquiring a(stats,'W'); r.lock(); }
+ void lock_shared() { LockStat::Acquiring a(stats,'R'); r.lock_shared(); }
+ void unlock() { stats.unlocking('W'); r.unlock(); }
+ void unlock_shared() { stats.unlocking('R'); r.unlock_shared(); }
};
class DBTryLockTimeoutException : public std::exception {
View
@@ -5,7 +5,7 @@ namespace mongo {
class LockStat {
enum { N = 4 };
public:
- Timer t;
+ Timer W_Timer;
unsigned long long timeAcquiring[N];
unsigned long long timeLocked[N];
@@ -17,6 +17,7 @@ namespace mongo {
}
struct Acquiring {
+ Timer tmr;
LockStat& ls;
unsigned type;
explicit Acquiring(LockStat&, char type);
@@ -33,12 +34,12 @@ namespace mongo {
inline BSONObj LockStat::report() const {
BSONObjBuilder x;
BSONObjBuilder y;
- x.append("R", (long long) timeLocked[0]);
+ //x.append("R", (long long) timeLocked[0]);
x.append("W", (long long) timeLocked[1]);
- if( timeLocked[2] || timeLocked[3] ) {
+ /*if( timeLocked[2] || timeLocked[3] ) {
x.append("r", (long long) timeLocked[2]);
x.append("w", (long long) timeLocked[3]);
- }
+ }*/
y.append("R", (long long) timeAcquiring[0]);
y.append("W", (long long) timeAcquiring[1]);
if( timeAcquiring[2] || timeAcquiring[3] ) {
@@ -66,18 +67,20 @@ namespace mongo {
inline LockStat::Acquiring::Acquiring(LockStat& _ls, char t) : ls(_ls) {
type = map(t);
dassert( type < N );
- ls.t.reset();
}
// note: we have race conditions on the following +=
// hmmm....
inline LockStat::Acquiring::~Acquiring() {
- ls.timeAcquiring[type] += ls.t.microsReset(); // reset to time how long we stay locked
+ ls.timeAcquiring[type] += tmr.micros();
+ if( type == 1 )
+ ls.W_Timer.reset();
}
inline void LockStat::unlocking(char tp) {
unsigned type = map(tp);
- timeLocked[type] += t.micros();
+ if( type == 1 )
+ timeLocked[type] += W_Timer.micros();
}
}

0 comments on commit de4a9b9

Please sign in to comment.