Don't grow the budget deficit once it's exceeded some number of seconds of transactions. Decay the deficit if the rate changes and it exceeds the new limit.
This commit is contained in:
parent
b2af17fb08
commit
90cb73d472
|
@ -272,6 +272,9 @@ ServerKnobs::ServerKnobs(bool randomize, ClientKnobs* clientKnobs) {
|
|||
init( START_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA, 0.1 );
|
||||
init( START_TRANSACTION_BATCH_QUEUE_CHECK_INTERVAL, 0.001 );
|
||||
init( START_TRANSACTION_MAX_TRANSACTIONS_TO_START, 100000 );
|
||||
init( START_TRANSACTION_MAX_BUDGET_DEFICIT_SECONDS, 5.0 ); if( randomize && BUGGIFY ) START_TRANSACTION_MAX_BUDGET_DEFICIT_SECONDS = deterministicRandom()->random01() * 60 + 0.1;
|
||||
// If the budget deficit exceeds the max budget deficit, the excess will decay by this fraction per second
|
||||
init( START_TRANSACTION_EXCESS_BUDGET_DEFICIT_DECAY, 0.2 ); if( randomize && BUGGIFY ) START_TRANSACTION_EXCESS_BUDGET_DEFICIT_DECAY = deterministicRandom()->random01();
|
||||
init( START_TRANSACTION_MAX_REQUESTS_TO_START, 10000 );
|
||||
|
||||
init( COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE, 0.0005 ); if( randomize && BUGGIFY ) COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE = 0.005;
|
||||
|
|
|
@ -216,6 +216,8 @@ public:
|
|||
double START_TRANSACTION_BATCH_INTERVAL_SMOOTHER_ALPHA;
|
||||
double START_TRANSACTION_BATCH_QUEUE_CHECK_INTERVAL;
|
||||
double START_TRANSACTION_MAX_TRANSACTIONS_TO_START;
|
||||
double START_TRANSACTION_MAX_BUDGET_DEFICIT_SECONDS;
|
||||
double START_TRANSACTION_EXCESS_BUDGET_DEFICIT_DECAY;
|
||||
int START_TRANSACTION_MAX_REQUESTS_TO_START;
|
||||
|
||||
double COMMIT_TRANSACTION_BATCH_INTERVAL_FROM_IDLE;
|
||||
|
|
|
@ -1108,6 +1108,11 @@ struct TransactionRateInfo {
|
|||
limit = std::min(0.0, limit) + rate * elapsed; // Adjust the limit based on the full elapsed interval in order to properly erase a deficit
|
||||
limit = std::min(limit, rate * SERVER_KNOBS->START_TRANSACTION_BATCH_INTERVAL_MAX); // Don't allow the rate to exceed what would be allowed in the maximum batch interval
|
||||
limit = std::min(limit, SERVER_KNOBS->START_TRANSACTION_MAX_TRANSACTIONS_TO_START);
|
||||
|
||||
double minBudget = -rate * SERVER_KNOBS->START_TRANSACTION_MAX_BUDGET_DEFICIT_SECONDS;
|
||||
if(limit < minBudget) {
|
||||
limit += (minBudget - limit) * pow(1.0-SERVER_KNOBS->START_TRANSACTION_EXCESS_BUDGET_DEFICIT_DECAY, elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
bool canStart(int64_t numAlreadyStarted) {
|
||||
|
@ -1115,7 +1120,10 @@ struct TransactionRateInfo {
|
|||
}
|
||||
|
||||
void updateBudget(int64_t numStarted) {
|
||||
limit -= numStarted;
|
||||
double minBudget = -rate * SERVER_KNOBS->START_TRANSACTION_MAX_BUDGET_DEFICIT_SECONDS;
|
||||
if(limit >= minBudget) {
|
||||
limit = std::max(limit - numStarted, minBudget);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue