summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2020-06-05 15:48:53 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-10 21:20:42 +0000
commitaf0d84cb6eaab138cae7ed690ca84b32a21eee6c (patch)
tree1e9c4acd4b6883078aca4a79da920afcb99b1b01 /src/mongo/db/curop.cpp
parentca520c2222a31734bb1ff9523941c86e55f283b5 (diff)
downloadmongo-af0d84cb6eaab138cae7ed690ca84b32a21eee6c.tar.gz
SERVER-47897 CurOp should use monotonic clock source for duration measurements
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r--src/mongo/db/curop.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index e3fe86be0e8..4fb6e0dfe6f 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -57,6 +57,7 @@
#include "mongo/util/log_with_sampling.h"
#include "mongo/util/net/socket_utils.h"
#include "mongo/util/str.h"
+#include "mongo/util/system_tick_source.h"
#include <mongo/db/stats/timer_stats.h>
namespace mongo {
@@ -348,6 +349,8 @@ CurOp::CurOp(OperationContext* opCtx) : CurOp(opCtx, &_curopStack(opCtx)) {
}
CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) : _stack(stack) {
+ _tickSource = SystemTickSource::get();
+
if (opCtx) {
_stack->push(opCtx, this);
} else {
@@ -408,7 +411,7 @@ void CurOp::setNS_inlock(StringData ns) {
void CurOp::ensureStarted() {
if (_start == 0) {
- _start = curTimeMicros64();
+ _start = _tickSource->getTicks();
}
}
@@ -435,10 +438,10 @@ bool CurOp::completeAndLogOperation(OperationContext* opCtx,
}
// Obtain the total execution time of this operation.
- _end = curTimeMicros64();
- _debug.executionTimeMicros = durationCount<Microseconds>(elapsedTimeExcludingPauses());
+ _end = _tickSource->getTicks();
+ _debug.executionTime = duration_cast<Microseconds>(elapsedTimeExcludingPauses());
- const auto executionTimeMillis = _debug.executionTimeMicros / 1000;
+ const auto executionTimeMillis = durationCount<Milliseconds>(_debug.executionTime);
if (_debug.isReplOplogGetMore) {
oplogGetMoreStats.recordMillis(executionTimeMillis);
@@ -841,7 +844,7 @@ string OpDebug::report(OperationContext* opCtx, const SingleThreadedLockStats* l
s << " remoteOpWaitMillis:" << durationCount<Milliseconds>(*remoteOpWaitTime);
}
- s << " " << (executionTimeMicros / 1000) << "ms";
+ s << " " << durationCount<Milliseconds>(executionTime) << "ms";
return s.str();
}
@@ -1010,7 +1013,7 @@ void OpDebug::report(OperationContext* opCtx,
pAttrs->add("remoteOpWaitMillis", durationCount<Milliseconds>(*remoteOpWaitTime));
}
- pAttrs->add("durationMillis", (executionTimeMicros / 1000));
+ pAttrs->add("durationMillis", durationCount<Milliseconds>(executionTime));
}
@@ -1132,7 +1135,7 @@ void OpDebug::append(OperationContext* opCtx,
b.append("remoteOpWaitMillis", durationCount<Milliseconds>(*remoteOpWaitTime));
}
- b.appendIntOrLL("millis", executionTimeMicros / 1000);
+ b.appendIntOrLL("millis", durationCount<Milliseconds>(executionTime));
if (!curop.getPlanSummary().empty()) {
b.append("planSummary", curop.getPlanSummary());