Update StorageQueueInfo::getTagThrottlingRatio implementation
This commit is contained in:
parent
2385dd36f3
commit
ae6167e576
|
@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue