summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorDan Pasette <dan@10gen.com>2013-05-22 22:38:52 -0400
committerDan Pasette <dan@10gen.com>2013-06-24 19:42:26 -0400
commit82674f15106984028627c9ecba18f84b55cd6dea (patch)
tree70b5d66c09dbe919f318d70548868c94e86679a0 /src/mongo/db
parenteb7ba8adc1ea407ebd88a8b829a6adbaf109e681 (diff)
downloadmongo-82674f15106984028627c9ecba18f84b55cd6dea.tar.gz
SERVER-9005 - Only record wtime metrics when w>1
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/dbcommands.cpp28
-rw-r--r--src/mongo/db/stats/timer_stats.cpp5
2 files changed, 26 insertions, 7 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 386f2fdbc26..0b3c1b97ba5 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -198,7 +198,21 @@ namespace mongo {
}
int timeout = cmdObj["wtimeout"].numberInt();
- TimerHolder timer( &gleWtimeStats );
+ scoped_ptr<TimerHolder> gleTimerHolder;
+ bool doTiming = false;
+ if ( e.isNumber() ) {
+ doTiming = e.numberInt() > 1;
+ }
+ else if ( e.type() == String ) {
+ doTiming = true;
+ }
+ TimerStats t;
+ if ( doTiming ) {
+ gleTimerHolder.reset( new TimerHolder( &gleWtimeStats ) );
+ }
+ else {
+ gleTimerHolder.reset( new TimerHolder( &t ) );
+ }
long long passes = 0;
char buf[32];
@@ -259,11 +273,11 @@ namespace mongo {
}
- if ( timeout > 0 && timer.millis() >= timeout ) {
+ if ( timeout > 0 && gleTimerHolder->millis() >= timeout ) {
gleWtimeouts.increment();
result.append( "wtimeout" , true );
errmsg = "timed out waiting for slaves";
- result.append( "waited" , timer.millis() );
+ result.append( "waited" , gleTimerHolder->millis() );
result.append("writtenTo", getHostsWrittenTo(op));
result.append( "err" , "timeout" );
return true;
@@ -275,9 +289,11 @@ namespace mongo {
killCurrentOp.checkForInterrupt();
}
- result.append("writtenTo", getHostsWrittenTo(op));
- int myMillis = timer.recordMillis();
- result.appendNumber( "wtime" , myMillis );
+ if ( doTiming ) {
+ result.append("writtenTo", getHostsWrittenTo(op));
+ int myMillis = gleTimerHolder->recordMillis();
+ result.appendNumber( "wtime" , myMillis );
+ }
}
result.appendNull( "err" );
diff --git a/src/mongo/db/stats/timer_stats.cpp b/src/mongo/db/stats/timer_stats.cpp
index 970f5671872..f0543b22123 100644
--- a/src/mongo/db/stats/timer_stats.cpp
+++ b/src/mongo/db/stats/timer_stats.cpp
@@ -31,7 +31,10 @@ namespace mongo {
int TimerHolder::recordMillis() {
_recorded = true;
- return _stats->record( _t );
+ if ( _stats ) {
+ return _stats->record( _t );
+ }
+ return _t.millis();
}
void TimerStats::recordMillis( int millis ) {