Rename epoch to release window in GrvTransactionRateInfo

The term "epoch" was used in too many places
This commit is contained in:
sfc-gh-tclinkenbeard 2022-10-05 09:29:12 -07:00
parent 8ff66d6fad
commit 31e8fb0490
4 changed files with 21 additions and 21 deletions

View File

@ -889,8 +889,8 @@ ACTOR static Future<Void> transactionStarter(GrvProxyInterface proxy,
}
tagQueue.runEpoch(elapsed, defaultQueue, batchQueue);
normalRateInfo.startEpoch();
batchRateInfo.startEpoch();
normalRateInfo.startReleaseWindow();
batchRateInfo.startReleaseWindow();
grvProxyData->stats.transactionLimit = normalRateInfo.getLimit();
grvProxyData->stats.batchTransactionLimit = batchRateInfo.getLimit();
@ -1000,11 +1000,11 @@ ACTOR static Future<Void> transactionStarter(GrvProxyInterface proxy,
transactionCount += transactionsStarted[0] + transactionsStarted[1];
batchTransactionCount += batchTotalStarted;
normalRateInfo.endEpoch(
normalRateInfo.endReleaseWindow(
systemTotalStarted + normalTotalStarted, systemQueue.empty() && defaultQueue.empty(), elapsed);
batchRateInfo.endEpoch(systemTotalStarted + normalTotalStarted + batchTotalStarted,
systemQueue.empty() && defaultQueue.empty() && batchQueue.empty(),
elapsed);
batchRateInfo.endReleaseWindow(systemTotalStarted + normalTotalStarted + batchTotalStarted,
systemQueue.empty() && defaultQueue.empty() && batchQueue.empty(),
elapsed);
if (debugID.present()) {
g_traceBatch.addEvent("TransactionDebug",

View File

@ -35,7 +35,7 @@ bool GrvTransactionRateInfo::canStart(int64_t numAlreadyStarted, int64_t count)
std::min(limit + budget, SERVER_KNOBS->START_TRANSACTION_MAX_TRANSACTIONS_TO_START);
}
void GrvTransactionRateInfo::endEpoch(int64_t numStartedAtPriority, bool queueEmptyAtPriority, double elapsed) {
void GrvTransactionRateInfo::endReleaseWindow(int64_t numStartedAtPriority, bool queueEmptyAtPriority, double elapsed) {
// Update the budget to accumulate any extra capacity available or remove any excess that was used.
// The actual delta is the portion of the limit we didn't use multiplied by the fraction of the window that
// elapsed.
@ -79,7 +79,7 @@ void GrvTransactionRateInfo::setRate(double rate) {
}
}
void GrvTransactionRateInfo::startEpoch() {
void GrvTransactionRateInfo::startReleaseWindow() {
// Determine the number of transactions that this proxy is allowed to release
// Roughly speaking, this is done by computing the number of transactions over some historical window that we
// could have started but didn't, and making that our limit. More precisely, we track a smoothed rate limit and
@ -100,10 +100,10 @@ ACTOR static Future<Void> mockClient(GrvTransactionRateInfo* rateInfo, double de
loop {
state double elapsed = (0.9 + 0.2 * deterministicRandom()->random01()) / desiredRate;
wait(delay(elapsed));
rateInfo->startEpoch();
rateInfo->startReleaseWindow();
int started = rateInfo->canStart(0, 1) ? 1 : 0;
*counter += started;
rateInfo->endEpoch(started, false, elapsed);
rateInfo->endReleaseWindow(started, false, elapsed);
}
}

View File

@ -44,7 +44,7 @@ void TagQueue::runEpoch(double elapsed,
SpannedDeque<GetReadVersionRequest>& outBatchPriority,
SpannedDeque<GetReadVersionRequest>& outDefaultPriority) {
for (auto& [_, rateInfo] : rateInfos) {
rateInfo.startEpoch();
rateInfo.startReleaseWindow();
}
Deque<DelayedRequest> newDelayedRequests;
@ -94,7 +94,7 @@ void TagQueue::runEpoch(double elapsed,
delayedRequests = std::move(newDelayedRequests);
for (auto& [tag, rateInfo] : rateInfos) {
rateInfo.endEpoch(std::move(releasedInEpoch)[tag], false, elapsed);
rateInfo.endReleaseWindow(std::move(releasedInEpoch)[tag], false, elapsed);
}
}

View File

@ -24,10 +24,10 @@
// Used by GRV Proxy to enforce rate limits received from the Ratekeeper.
//
// Between delays, the GrvTransactionRateInfo executes an "epoch" starting
// with a call to the startEpoch method. Within this epoch, transactions are
// released while canStart returns true. At the end of the epoch, the
// endEpoch method is called, and the budget is updated to add or
// Between waits, the GrvTransactionRateInfo executes an "release window" starting
// with a call to the startReleaseWindow method. Within this release window, transactions are
// released while canStart returns true. At the end of the release window, the
// endReleaseWindow method is called, and the budget is updated to add or
// remove capacity.
//
// Meanwhile, the desired rate is updated through the setRate method.
@ -45,17 +45,17 @@ public:
explicit GrvTransactionRateInfo(double rate = 0.0);
// Determines the number of transactions that this proxy is allowed to release
// in this epoch.
void startEpoch();
// in this release window.
void startReleaseWindow();
// Checks if a "count" new transactions can be released, given that
// "numAlreadyStarted" transactions have already been released in the
// current epoch.
// current release window.
bool canStart(int64_t numAlreadyStarted, int64_t count) const;
// Updates the budget to accumulate any extra capacity available or remove any excess that was used.
// Call at the end of an epoch.
void endEpoch(int64_t numStartedAtPriority, bool queueEmptyAtPriority, double elapsed);
// Call at the end of a release window.
void endReleaseWindow(int64_t numStartedAtPriority, bool queueEmptyAtPriority, double elapsed);
// Smoothly sets rate. If currently disabled, reenable
void setRate(double rate);