Permalink
Browse files

SERVER-6391 - don't sleep if we're a reader,

and call ElapsedTracker::resetLastTime when we're done sleeping

Conflicts:

	db/clientcursor.cpp
  • Loading branch information...
1 parent 8e42151 commit de0cfcd8de67c52b8206a27b7a5a939e70520051 @erh erh committed Jul 16, 2012
Showing with 18 additions and 6 deletions.
  1. +18 −6 db/clientcursor.cpp
View
@@ -457,7 +457,9 @@ namespace mongo {
if ( yielded ) {
*yielded = true;
}
- return yield( yieldSuggest() , rec );
+ bool res = yield( yieldSuggest() , rec );
+ _yieldSometimesTracker.resetLastTime();
+ return res;
}
return true;
}
@@ -467,12 +469,16 @@ namespace mongo {
if ( yielded ) {
*yielded = true;
}
- return yield( micros , _recordForYield( need ) );
+ bool res = yield( micros , _recordForYield( need ) );
+ _yieldSometimesTracker.resetLastTime();
+ return res;
}
return true;
}
void ClientCursor::staticYield( int micros , const StringData& ns , Record * rec ) {
+ bool haveReadLock = dbMutex.atLeastReadLocked() && ! dbMutex.isWriteLocked();
+
killCurrentOp.checkForInterrupt( false );
{
auto_ptr<RWLockRecursive::Shared> lk;
@@ -481,10 +487,16 @@ namespace mongo {
dbtempreleasecond unlock;
if ( unlock.unlocked() ) {
- if ( micros == -1 )
- micros = Client::recommendedYieldMicros();
- if ( micros > 0 )
- sleepmicros( micros );
+ if ( haveReadLock ) {
+ // don't sleep with a read lock
+ }
+ else {
+ if ( micros == -1 )
+ micros = Client::recommendedYieldMicros();
+ if ( micros > 0 )
+ sleepmicros( micros );
+ }
+
}
else {
CurOp * c = cc().curop();

0 comments on commit de0cfcd

Please sign in to comment.