Fix get*OperationCost functions for empty mutations/results

This commit is contained in:
sfc-gh-tclinkenbeard 2023-05-28 12:56:46 -07:00
parent d0e9a14b73
commit 0cfbe4ccc1
2 changed files with 15 additions and 6 deletions

View File

@ -618,13 +618,21 @@ ACTOR Future<bool> checkSafeExclusions(Database cx, std::vector<AddressExclusion
// Measured in bytes, rounded up to the nearest page size. Multiply by fungibility ratio
// because writes are more expensive than reads.
inline uint64_t getWriteOperationCost(uint64_t bytes) {
return CLIENT_KNOBS->GLOBAL_TAG_THROTTLING_RW_FUNGIBILITY_RATIO * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE *
((bytes - 1) / CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE + 1);
if (bytes == 0) {
return CLIENT_KNOBS->GLOBAL_TAG_THROTTLING_RW_FUNGIBILITY_RATIO * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE;
} else {
return CLIENT_KNOBS->GLOBAL_TAG_THROTTLING_RW_FUNGIBILITY_RATIO * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE *
((bytes - 1) / CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE + 1);
}
}
// Measured in bytes, rounded up to the nearest page size.
inline uint64_t getReadOperationCost(uint64_t bytes) {
return ((bytes - 1) / CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE + 1) * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE;
if (bytes == 0) {
return CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE;
} else {
return ((bytes - 1) / CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE + 1) * CLIENT_KNOBS->TAG_THROTTLING_PAGE_SIZE;
}
}
// Create a transaction to set the value of system key \xff/conf/perpetual_storage_wiggle. If enable == true, the value

View File

@ -70,8 +70,8 @@ RkTagThrottleCollection& RkTagThrottleCollection::RkTagThrottleCollection::opera
double RkTagThrottleCollection::computeTargetTpsRate(double currentBusyness,
double targetBusyness,
double requestRate) {
ASSERT_GT(currentBusyness, 0);
ASSERT_GT(currentBusyness, 0.0);
ASSERT_LE(currentBusyness, 1.0);
if (targetBusyness < 1) {
double targetFraction = targetBusyness * (1 - currentBusyness) / ((1 - targetBusyness) * currentBusyness);
return requestRate * targetFraction;
@ -135,7 +135,8 @@ Optional<double> RkTagThrottleCollection::autoThrottleTag(UID id,
expiration = now() + SERVER_KNOBS->AUTO_TAG_THROTTLE_DURATION;
}
ASSERT(tpsRate.present() && tpsRate.get() >= 0);
ASSERT(tpsRate.present());
ASSERT_GE(tpsRate.get(), 0);
throttle.limits.tpsRate = tpsRate.get();
throttle.limits.expiration = expiration.get();