From 20ac60fb11681dc11b48e2617d7f6bcb47945714 Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Mon, 18 Jul 2022 21:25:35 -0700 Subject: [PATCH] Set throttling ratio in GlobalTagThrottler::tryUpdateAutoThrottling --- fdbserver/GlobalTagThrottler.actor.cpp | 32 +++------------------- fdbserver/Ratekeeper.actor.cpp | 19 ++++--------- fdbserver/include/fdbserver/Ratekeeper.h | 2 +- fdbserver/include/fdbserver/TagThrottler.h | 4 --- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/fdbserver/GlobalTagThrottler.actor.cpp b/fdbserver/GlobalTagThrottler.actor.cpp index 8ee2a6a140..b2d2930ffb 100644 --- a/fdbserver/GlobalTagThrottler.actor.cpp +++ b/fdbserver/GlobalTagThrottler.actor.cpp @@ -527,6 +527,8 @@ public: int64_t manualThrottleCount() const { return 0; } Future tryUpdateAutoThrottling(StorageQueueInfo const& ss) { + throttlingRatios[ss.id] = ss.getThrottlingRatio(SERVER_KNOBS->TARGET_BYTES_PER_STORAGE_SERVER, + SERVER_KNOBS->SPRING_BYTES_STORAGE_SERVER); for (const auto& busyReadTag : ss.busiestReadTags) { throughput[ss.id][busyReadTag.tag].updateCost(busyReadTag.rate, OpType::READ); } @@ -536,8 +538,6 @@ public: return Void(); } - void setThrottlingRatio(UID storageServerId, Optional ratio) { throttlingRatios[storageServerId] = ratio; } - void setQuota(TransactionTagRef tag, ThrottleApi::TagQuotaValue const& tagQuotaValue) { tagStatistics[tag].setQuota(tagQuotaValue); } @@ -580,10 +580,6 @@ Future GlobalTagThrottler::tryUpdateAutoThrottling(StorageQueueInfo const& return impl->tryUpdateAutoThrottling(ss); } -void GlobalTagThrottler::setThrottlingRatio(UID storageServerId, Optional ratio) { - return impl->setThrottlingRatio(storageServerId, ratio); -} - void GlobalTagThrottler::setQuota(TransactionTagRef tag, ThrottleApi::TagQuotaValue const& tagQuotaValue) { return impl->setQuota(tag, tagQuotaValue); } @@ -645,18 +641,10 @@ public: double fractionalBusyness{ 0.0 }; // unused for global tag throttling result.busiestWriteTags.emplace_back(tag, writeCost.smoothRate(), fractionalBusyness); } + result.lastReply.bytesInput = ((totalReadCost.smoothRate() + totalWriteCost.smoothRate()) / targetCost) * + SERVER_KNOBS->TARGET_BYTES_PER_STORAGE_SERVER; return result; } - - Optional getThrottlingRatio() const { - auto const springCost = 0.2 * targetCost; - auto const currentCost = totalReadCost.smoothRate() + totalWriteCost.smoothRate(); - if (currentCost < targetCost - springCost) { - return {}; - } else { - return std::max(0.0, ((targetCost + springCost) - currentCost) / springCost); - } - } }; class StorageServerCollection { @@ -693,14 +681,6 @@ public: } return result; } - - std::map> getThrottlingRatios() const { - std::map> result; - for (int i = 0; i < storageServers.size(); ++i) { - result[UID(i, i)] = storageServers[i].getThrottlingRatio(); - } - return result; - } }; ACTOR static Future runClient(GlobalTagThrottler* globalTagThrottler, @@ -766,10 +746,6 @@ ACTOR static Future updateGlobalTagThrottler(GlobalTagThrottler* globalTag for (const auto& sq : storageQueueInfos) { globalTagThrottler->tryUpdateAutoThrottling(sq); } - auto const throttlingRatios = storageServers->getThrottlingRatios(); - for (const auto& [id, ratio] : throttlingRatios) { - globalTagThrottler->setThrottlingRatio(id, ratio); - } } } diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index bde7ef6410..a5383bc1f6 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -1018,22 +1018,13 @@ void StorageQueueInfo::refreshCommitCost(double elapsed) { totalWriteCosts = 0; } -Optional StorageQueueInfo::getWriteQueueSizeLimitRatio(int64_t storageSpringBytes, - int64_t storageTargetBytes) const { - auto const minFreeSpace = - std::max(SERVER_KNOBS->MIN_AVAILABLE_SPACE, - (int64_t)(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO * smoothTotalSpace.smoothTotal())); +Optional StorageQueueInfo::getThrottlingRatio(int64_t storageTargetBytes, int64_t storageSpringBytes) const { auto const storageQueue = getStorageQueueBytes(); - auto const springBytes = std::max( - 1, std::min(storageSpringBytes, (smoothFreeSpace.smoothTotal() - minFreeSpace) * 0.2)); - auto const targetBytes = - std::max(1, std::min(storageTargetBytes, smoothFreeSpace.smoothTotal() - minFreeSpace)); - auto const targetRateRatio = std::min((storageQueue - targetBytes + springBytes) / (double)springBytes, 2.0); - auto const inputRate = smoothInputBytes.smoothRate(); - if (targetRateRatio > 0 && inputRate > 0) { - return verySmoothDurableBytes.smoothRate() / (inputRate * targetRateRatio); - } else { + if (storageQueue < storageTargetBytes - storageSpringBytes) { return {}; + } else { + return std::max( + 0.0, static_cast((storageTargetBytes + storageSpringBytes) - storageQueue) / storageSpringBytes); } } diff --git a/fdbserver/include/fdbserver/Ratekeeper.h b/fdbserver/include/fdbserver/Ratekeeper.h index a2c79cede9..1b7a3f990a 100644 --- a/fdbserver/include/fdbserver/Ratekeeper.h +++ b/fdbserver/include/fdbserver/Ratekeeper.h @@ -75,7 +75,7 @@ public: void addCommitCost(TransactionTagRef tagName, TransactionCommitCostEstimation const& cost); // Determine the ratio (limit / current throughput) for throttling based on write queue size - Optional getWriteQueueSizeLimitRatio(int64_t storageSpringBytes, int64_t storageTargetBytes) const; + Optional getThrottlingRatio(int64_t storageTargetBytes, int64_t storageSpringBytes) const; }; struct TLogQueueInfo { diff --git a/fdbserver/include/fdbserver/TagThrottler.h b/fdbserver/include/fdbserver/TagThrottler.h index bd739f9880..146aa0851c 100644 --- a/fdbserver/include/fdbserver/TagThrottler.h +++ b/fdbserver/include/fdbserver/TagThrottler.h @@ -90,10 +90,6 @@ public: Future tryUpdateAutoThrottling(StorageQueueInfo const&) override; PrioritizedTransactionTagMap getClientRates() override; - // Based on limiting storage queue size, set a ratio by which total throughput on the storage server needs to be - // adjusted - void setThrottlingRatio(UID storageServerId, Optional ratio); - // Testing only: public: void setQuota(TransactionTagRef, ThrottleApi::TagQuotaValue const&);