Update StorageQueueInfo::getTagThrottlingRatio implementation

This commit is contained in:
sfc-gh-tclinkenbeard 2023-05-26 11:03:37 -07:00 committed by Trevor Clinkenbeard
parent 2385dd36f3
commit ae6167e576
1 changed files with 6 additions and 4 deletions

View File

@ -1391,11 +1391,13 @@ UpdateCommitCostRequest StorageQueueInfo::refreshCommitCost(double elapsed) {
Optional<double> StorageQueueInfo::getTagThrottlingRatio(int64_t storageTargetBytes, int64_t storageSpringBytes) const { Optional<double> StorageQueueInfo::getTagThrottlingRatio(int64_t storageTargetBytes, int64_t storageSpringBytes) const {
auto const storageQueue = getStorageQueueBytes(); auto const storageQueue = getStorageQueueBytes();
if (storageQueue < storageTargetBytes - storageSpringBytes) { // TODO: Remove duplicate calculation from Ratekeeper::updateRate
return {}; double inverseResult = std::min(
2.0, (storageQueue - storageTargetBytes + storageSpringBytes) / static_cast<double>(storageSpringBytes));
if (inverseResult > 0) {
return 1.0 / inverseResult;
} else { } else {
return std::max( return {};
0.0, static_cast<double>((storageTargetBytes + storageSpringBytes) - storageQueue) / storageSpringBytes);
} }
} }