diff options
author | LaMont Nelson <lamont.nelson@mongodb.com> | 2020-07-25 02:06:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-05 16:56:01 +0000 |
commit | b2c1fa4f121fdb6cdffa924b802271d68c3367a3 (patch) | |
tree | 6310ec0c55f64cd1b9c340c92e863390d4ea87fc /src/mongo/client/async_client.cpp | |
parent | 14ef67e5d039a491ef897edd49bd7d075a18029c (diff) | |
download | mongo-b2c1fa4f121fdb6cdffa924b802271d68c3367a3.tar.gz |
SERVER-49694: fix latency measurement in RSM; change latency measurement for command responses to Microseconds
Diffstat (limited to 'src/mongo/client/async_client.cpp')
-rw-r--r-- | src/mongo/client/async_client.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/mongo/client/async_client.cpp b/src/mongo/client/async_client.cpp index d3df41d9705..692f38191f5 100644 --- a/src/mongo/client/async_client.cpp +++ b/src/mongo/client/async_client.cpp @@ -226,18 +226,14 @@ Future<void> AsyncDBClient::initWireVersion(const std::string& appName, // have to communicate with servers that do not support other protocols. auto requestMsg = rpc::legacyRequestFromOpMsgRequest(OpMsgRequest::fromDBAndBody("admin", requestObj)); - auto clkSource = _svcCtx->getFastClockSource(); - auto start = clkSource->now(); - auto msgId = nextMessageId(); return _call(requestMsg, msgId) .then([msgId, this]() { return _waitForResponse(msgId); }) - .then([this, requestObj, hook, clkSource, start](Message response) { + .then([this, requestObj, hook, timer = Timer{}](Message response) { auto cmdReply = rpc::makeReply(&response); _parseIsMasterResponse(requestObj, cmdReply); if (hook) { - auto millis = duration_cast<Milliseconds>(clkSource->now() - start); - executor::RemoteCommandResponse cmdResp(*cmdReply, millis); + executor::RemoteCommandResponse cmdResp(*cmdReply, timer.elapsed()); uassertStatusOK(hook->validateHost(_peer, requestObj, std::move(cmdResp))); } }); @@ -310,16 +306,14 @@ Future<rpc::UniqueReply> AsyncDBClient::runCommand(OpMsgRequest request, Future<executor::RemoteCommandResponse> AsyncDBClient::runCommandRequest( executor::RemoteCommandRequest request, const BatonHandle& baton) { - auto clkSource = _svcCtx->getPreciseClockSource(); - auto start = clkSource->now(); + auto startTimer = Timer(); auto opMsgRequest = OpMsgRequest::fromDBAndBody( std::move(request.dbname), std::move(request.cmdObj), std::move(request.metadata)); auto fireAndForget = request.fireAndForgetMode == executor::RemoteCommandRequest::FireAndForgetMode::kOn; return runCommand(std::move(opMsgRequest), baton, fireAndForget) - .then([start, clkSource, this](rpc::UniqueReply response) { - auto duration = duration_cast<Milliseconds>(clkSource->now() - start); - return executor::RemoteCommandResponse(*response, duration); + .then([this, startTimer = std::move(startTimer)](rpc::UniqueReply response) { + return executor::RemoteCommandResponse(*response, startTimer.elapsed()); }); } |