From 62bee7ac9a7cc6d3dbba9923a5ebe6625d2891f0 Mon Sep 17 00:00:00 2001 From: Hao Fu <77984096+hfu94@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:54:31 -0700 Subject: [PATCH] Add g_traceBatch for prefetch query (#7730) --- fdbserver/storageserver.actor.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 2785008cd2..436436d344 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -3818,6 +3818,9 @@ ACTOR Future quickGetKeyValues( state double getValuesStart = g_network->timer(); getRange.begin = firstGreaterOrEqual(KeyRef(*a, prefix)); getRange.end = firstGreaterOrEqual(strinc(prefix, *a)); + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent( + "TransactionDebug", pOriginalReq->debugID.get().first(), "storageserver.quickGetKeyValues.Before"); try { // TODO: Use a lower level API may be better? Or tweak priorities? GetKeyValuesRequest req; @@ -3848,6 +3851,10 @@ ACTOR Future quickGetKeyValues( getRange.result = RangeResultRef(reply.data, reply.more); const double duration = g_network->timer() - getValuesStart; data->counters.mappedRangeLocalSample.addMeasurement(duration); + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent("TransactionDebug", + pOriginalReq->debugID.get().first(), + "storageserver.quickGetKeyValues.AfterLocalFetch"); return getRange; } // Otherwise fallback. @@ -3869,6 +3876,10 @@ ACTOR Future quickGetKeyValues( getRange.result = rangeResult; const double duration = g_network->timer() - getValuesStart; data->counters.mappedRangeRemoteSample.addMeasurement(duration); + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent("TransactionDebug", + pOriginalReq->debugID.get().first(), + "storageserver.quickGetKeyValues.AfterRemoteFetch"); return getRange; } else { throw quick_get_key_values_miss(); @@ -4156,7 +4167,9 @@ ACTOR Future mapKeyValues(StorageServer* data, result.arena.dependsOn(input.arena); result.data.reserve(result.arena, input.data.size()); - + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent( + "TransactionDebug", pOriginalReq->debugID.get().first(), "storageserver.mapKeyValues.Start"); state Tuple mappedKeyFormatTuple; state Tuple mappedKeyTuple; @@ -4175,6 +4188,9 @@ ACTOR Future mapKeyValues(StorageServer* data, state std::vector kvms(k); state std::vector> subqueries; state int offset = 0; + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent( + "TransactionDebug", pOriginalReq->debugID.get().first(), "storageserver.mapKeyValues.BeforeLoop"); for (; offset < sz; offset += SERVER_KNOBS->MAX_PARALLEL_QUICK_GET_VALUE) { // Divide into batches of MAX_PARALLEL_QUICK_GET_VALUE subqueries for (int i = 0; i + offset < sz && i < SERVER_KNOBS->MAX_PARALLEL_QUICK_GET_VALUE; i++) { @@ -4210,11 +4226,17 @@ ACTOR Future mapKeyValues(StorageServer* data, mappedKey)); } wait(waitForAll(subqueries)); + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent( + "TransactionDebug", pOriginalReq->debugID.get().first(), "storageserver.mapKeyValues.AfterBatch"); subqueries.clear(); for (int i = 0; i + offset < sz && i < SERVER_KNOBS->MAX_PARALLEL_QUICK_GET_VALUE; i++) { result.data.push_back(result.arena, kvms[i]); } } + if (pOriginalReq->debugID.present()) + g_traceBatch.addEvent( + "TransactionDebug", pOriginalReq->debugID.get().first(), "storageserver.mapKeyValues.AfterAll"); return result; }