From 25fb63e68a38877d07896f69188cc0481797b7ec Mon Sep 17 00:00:00 2001 From: Xin Dong Date: Fri, 8 Nov 2019 10:49:38 -0800 Subject: [PATCH] For performance concerns, change the read sampling when doing a range read. Now it bills the total cost of a range read to the start key of the range returned. --- fdbserver/storageserver.actor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index e11d04cb8e..868edcc006 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1448,10 +1448,15 @@ ACTOR Future getKeyValues( StorageServer* data, GetKeyValuesRequest req ) data->metrics.notify(r.data[i].key, m); }*/ + // For performance concerns, the cost of a range read is billed to the start key of the range. + int64_t totalByteSize = 0; for (int i = 0; i < r.data.size(); i++) { + totalByteSize += r.data[i].expectedSize(); + } + if (totalByteSize > 0) { StorageMetrics m; - m.bytesReadPerKSecond = std::max((int64_t)r.data[i].expectedSize(), SERVER_KNOBS->EMPTY_READ_PENALTY); - data->metrics.notify(r.data[i].key, m); + m.bytesReadPerKSecond = std::max(totalByteSize, SERVER_KNOBS->EMPTY_READ_PENALTY); + data->metrics.notify(r.data[0].key, m); } r.penalty = data->getPenalty();