From 4c07dd8b8e1a951e825c367eb377dc15a6c73af5 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 15 Apr 2024 18:16:48 -0700 Subject: [PATCH 1/2] Move AutoTimer after transaction --- BedrockCore.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BedrockCore.cpp b/BedrockCore.cpp index c37715d2b..4377fc5e2 100644 --- a/BedrockCore.cpp +++ b/BedrockCore.cpp @@ -125,7 +125,6 @@ void BedrockCore::prePeekCommand(unique_ptr& command) { } BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr& command, bool exclusive) { - AutoTimer timer(command, exclusive ? BedrockCommand::BLOCKING_PEEK : BedrockCommand::PEEK); BedrockServer::ScopedStateSnapshot snapshot(_server); command->lastPeekedOrProcessedInState = _server.getState(); @@ -146,6 +145,9 @@ BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr& command STHROW("501 Failed to begin " + (exclusive ? "exclusive"s : "shared"s) + " transaction"); } + // We start the timer here to avoid including the time spent acquiring the the lock _sharedData.commitLock + AutoTimer timer(command, exclusive ? BedrockCommand::BLOCKING_PEEK : BedrockCommand::PEEK); + // Make sure no writes happen while in peek command _db.setQueryOnly(true); From e2b984b21dfbdd79b8c1654ad429214948e65713 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 15 Apr 2024 18:21:07 -0700 Subject: [PATCH 2/2] Fix comment --- BedrockCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BedrockCore.cpp b/BedrockCore.cpp index 4377fc5e2..40f35edf9 100644 --- a/BedrockCore.cpp +++ b/BedrockCore.cpp @@ -145,7 +145,7 @@ BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr& command STHROW("501 Failed to begin " + (exclusive ? "exclusive"s : "shared"s) + " transaction"); } - // We start the timer here to avoid including the time spent acquiring the the lock _sharedData.commitLock + // We start the timer here to avoid including the time spent acquiring the lock _sharedData.commitLock AutoTimer timer(command, exclusive ? BedrockCommand::BLOCKING_PEEK : BedrockCommand::PEEK); // Make sure no writes happen while in peek command