Merge pull request #10725 from sfc-gh-tclinkenbeard/main-throttle-multiple-write-tags

Monitor multiple write tags in `StorageQueueInfo::refreshCommitCost`
This commit is contained in:
Jingyu Zhou 2023-09-20 20:44:34 -07:00 committed by GitHub
commit 3ebbe8c7a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 6 deletions

View File

@ -1403,20 +1403,31 @@ UpdateCommitCostRequest StorageQueueInfo::refreshCommitCost(double elapsed) {
busiestWriteTags.clear();
TransactionTag busiestTag;
TransactionCommitCostEstimation maxCost;
double maxRate = 0, maxBusyness = 0;
double maxRate = 0;
std::priority_queue<BusyTagInfo, std::vector<BusyTagInfo>, std::greater<BusyTagInfo>> topKWriters;
for (const auto& [tag, cost] : tagCostEst) {
double rate = cost.getCostSum() / elapsed;
double busyness = static_cast<double>(maxCost.getCostSum()) / totalWriteCosts;
if (rate < SERVER_KNOBS->MIN_TAG_WRITE_PAGES_RATE * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE) {
continue;
}
if (topKWriters.size() < SERVER_KNOBS->SS_THROTTLE_TAGS_TRACKED) {
topKWriters.emplace(tag, rate, busyness);
} else if (topKWriters.top().rate < rate) {
topKWriters.pop();
topKWriters.emplace(tag, rate, busyness);
}
if (rate > maxRate) {
busiestTag = tag;
maxRate = rate;
maxCost = cost;
}
}
if (maxRate > SERVER_KNOBS->MIN_TAG_WRITE_PAGES_RATE * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE) {
// TraceEvent("RefreshSSCommitCost").detail("TotalWriteCost", totalWriteCost).detail("TotalWriteOps",totalWriteOps);
ASSERT_GT(totalWriteCosts, 0);
maxBusyness = double(maxCost.getCostSum()) / totalWriteCosts;
busiestWriteTags.emplace_back(busiestTag, maxRate, maxBusyness);
while (!topKWriters.empty()) {
busiestWriteTags.push_back(std::move(topKWriters.top()));
topKWriters.pop();
}
UpdateCommitCostRequest updateCommitCostRequest{ ratekeeperID,