From 455b75abca3b8f27853ca2c0206227bbae0c5c1d Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Wed, 2 Mar 2022 18:43:49 -0800 Subject: [PATCH] Use structured bindings for for loop in Ratekeeper::refreshStorageServerCommitCost --- fdbserver/Ratekeeper.actor.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index 1d12c6f1d8..9eddcfc2ec 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -971,12 +971,12 @@ Future Ratekeeper::refreshStorageServerCommitCost() { } double elapsed = now() - lastBusiestCommitTagPick; // for each SS, select the busiest commit tag from ssTrTagCommitCost - for (auto it = storageQueueInfo.begin(); it != storageQueueInfo.end(); ++it) { - it->value.busiestWriteTags.clear(); + for (auto& [ssId, ssQueueInfo] : storageQueueInfo) { + ssQueueInfo.busiestWriteTags.clear(); TransactionTag busiestTag; TransactionCommitCostEstimation maxCost; double maxRate = 0, maxBusyness = 0; - for (const auto& [tag, cost] : it->value.tagCostEst) { + for (const auto& [tag, cost] : ssQueueInfo.tagCostEst) { double rate = cost.getCostSum() / elapsed; if (rate > maxRate) { busiestTag = tag; @@ -986,24 +986,24 @@ Future Ratekeeper::refreshStorageServerCommitCost() { } if (maxRate > SERVER_KNOBS->MIN_TAG_WRITE_PAGES_RATE) { // TraceEvent("RefreshSSCommitCost").detail("TotalWriteCost", it->value.totalWriteCost).detail("TotalWriteOps",it->value.totalWriteOps); - ASSERT_GT(it->value.totalWriteCosts, 0); - maxBusyness = double(maxCost.getCostSum()) / it->value.totalWriteCosts; - it->value.busiestWriteTags.emplace_back(busiestTag, maxBusyness, maxRate); + ASSERT_GT(ssQueueInfo.totalWriteCosts, 0); + maxBusyness = double(maxCost.getCostSum()) / ssQueueInfo.totalWriteCosts; + ssQueueInfo.busiestWriteTags.emplace_back(busiestTag, maxBusyness, maxRate); } - TraceEvent("BusiestWriteTag", it->key) + TraceEvent("BusiestWriteTag", ssId) .detail("Elapsed", elapsed) .detail("Tag", printable(busiestTag)) .detail("TagOps", maxCost.getOpsSum()) .detail("TagCost", maxCost.getCostSum()) - .detail("TotalCost", it->value.totalWriteCosts) - .detail("Reported", !it->value.busiestWriteTags.empty()) - .trackLatest(it->value.busiestWriteTagEventHolder->trackingKey); + .detail("TotalCost", ssQueueInfo.totalWriteCosts) + .detail("Reported", !ssQueueInfo.busiestWriteTags.empty()) + .trackLatest(ssQueueInfo.busiestWriteTagEventHolder->trackingKey); // reset statistics - it->value.tagCostEst.clear(); - it->value.totalWriteOps = 0; - it->value.totalWriteCosts = 0; + ssQueueInfo.tagCostEst.clear(); + ssQueueInfo.totalWriteOps = 0; + ssQueueInfo.totalWriteCosts = 0; } lastBusiestCommitTagPick = now(); return Void();