Reenable GlobalTagThrottler_GotClientRate trace events

This commit is contained in:
sfc-gh-tclinkenbeard 2022-07-19 09:25:08 -07:00
parent f197314cb5
commit 8a18fa23cf

View File

@ -405,7 +405,16 @@ class GlobalTagThrottlerImpl {
} }
} }
Optional<double> getTargetTps(TransactionTag tag, bool& isReadBusy, bool& isWriteBusy) const { public:
GlobalTagThrottlerImpl(Database db, UID id) : db(db), id(id) {}
Future<Void> monitorThrottlingChanges() { return monitorThrottlingChanges(this); }
void addRequests(TransactionTag tag, int count) { tagStatistics[tag].addTransactions(count); }
uint64_t getThrottledTagChangeId() const { return throttledTagChangeId; }
PrioritizedTransactionTagMap<ClientTagThrottleLimits> getClientRates() {
PrioritizedTransactionTagMap<ClientTagThrottleLimits> result;
lastBusyReadTagCount = lastBusyWriteTagCount = 0;
for (auto& [tag, stats] : tagStatistics) {
// Currently there is no differentiation between batch priority and default priority transactions
auto const readLimitingTps = getLimitingTps(tag, OpType::READ); auto const readLimitingTps = getLimitingTps(tag, OpType::READ);
auto const writeLimitingTps = getLimitingTps(tag, OpType::WRITE); auto const writeLimitingTps = getLimitingTps(tag, OpType::WRITE);
Optional<double> limitingTps; Optional<double> limitingTps;
@ -431,14 +440,14 @@ class GlobalTagThrottlerImpl {
} }
if (!desiredTps.present()) { if (!desiredTps.present()) {
return {}; continue;
} }
if (readLimitingTps.present() && readLimitingTps.get() < readDesiredTps.orDefault(0)) { if (readLimitingTps.present() && readLimitingTps.get() < readDesiredTps.orDefault(0)) {
isReadBusy = true; ++lastBusyReadTagCount;
} }
if (writeLimitingTps.present() && writeLimitingTps.get() < writeDesiredTps.orDefault(0)) { if (writeLimitingTps.present() && writeLimitingTps.get() < writeDesiredTps.orDefault(0)) {
isWriteBusy = true; ++lastBusyWriteTagCount;
} }
auto const readReservedTps = getReservedTps(tag, OpType::READ, averageTransactionReadCost); auto const readReservedTps = getReservedTps(tag, OpType::READ, averageTransactionReadCost);
@ -459,35 +468,10 @@ class GlobalTagThrottlerImpl {
if (reservedTps.present()) { if (reservedTps.present()) {
targetTps = std::max(targetTps, reservedTps.get()); targetTps = std::max(targetTps, reservedTps.get());
} }
return targetTps;
}
public: auto const clientRate = stats.updateAndGetPerClientLimit(targetTps);
GlobalTagThrottlerImpl(Database db, UID id) : db(db), id(id) {}
Future<Void> monitorThrottlingChanges() { return monitorThrottlingChanges(this); }
void addRequests(TransactionTag tag, int count) { tagStatistics[tag].addTransactions(count); }
uint64_t getThrottledTagChangeId() const { return throttledTagChangeId; }
PrioritizedTransactionTagMap<ClientTagThrottleLimits> getClientRates() {
PrioritizedTransactionTagMap<ClientTagThrottleLimits> result;
lastBusyReadTagCount = lastBusyWriteTagCount = 0;
for (auto& [tag, stats] : tagStatistics) {
// Currently there is no differentiation between batch priority and default priority transactions
auto isReadBusy = false;
auto isWriteBusy = false;
auto const targetTps = getTargetTps(tag, isReadBusy, isWriteBusy);
if (isReadBusy) {
++lastBusyReadTagCount;
}
if (isWriteBusy) {
++lastBusyWriteTagCount;
}
if (!targetTps.present()) {
continue;
}
auto const clientRate = stats.updateAndGetPerClientLimit(targetTps.get());
result[TransactionPriority::BATCH][tag] = result[TransactionPriority::DEFAULT][tag] = clientRate; result[TransactionPriority::BATCH][tag] = result[TransactionPriority::DEFAULT][tag] = clientRate;
/*
TraceEvent("GlobalTagThrottler_GotClientRate", id) TraceEvent("GlobalTagThrottler_GotClientRate", id)
.detail("Tag", printable(tag)) .detail("Tag", printable(tag))
.detail("TargetTps", targetTps) .detail("TargetTps", targetTps)
@ -498,10 +482,10 @@ public:
.detail("ReservedTps", reservedTps) .detail("ReservedTps", reservedTps)
.detail("DesiredTps", desiredTps) .detail("DesiredTps", desiredTps)
.detail("NumStorageServers", throughput.size()); .detail("NumStorageServers", throughput.size());
*/
} }
return result; return result;
} }
int64_t autoThrottleCount() const { int64_t autoThrottleCount() const {
int64_t result{ 0 }; int64_t result{ 0 };
for (const auto& [tag, stats] : tagStatistics) { for (const auto& [tag, stats] : tagStatistics) {