mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Add StorageQueueInfo::getWriteQueueSizeLimitRatio method
This commit is contained in:
parent
bc62b538b1
commit
b49c36f0b0
@ -1018,6 +1018,25 @@ void StorageQueueInfo::refreshCommitCost(double elapsed) {
|
|||||||
totalWriteCosts = 0;
|
totalWriteCosts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<double> StorageQueueInfo::getWriteQueueSizeLimitRatio(int64_t storageSpringBytes,
|
||||||
|
int64_t storageTargetBytes) const {
|
||||||
|
auto const minFreeSpace =
|
||||||
|
std::max(SERVER_KNOBS->MIN_AVAILABLE_SPACE,
|
||||||
|
(int64_t)(SERVER_KNOBS->MIN_AVAILABLE_SPACE_RATIO * smoothTotalSpace.smoothTotal()));
|
||||||
|
auto const storageQueue = getStorageQueueBytes();
|
||||||
|
auto const springBytes = std::max<int64_t>(
|
||||||
|
1, std::min<int64_t>(storageSpringBytes, (smoothFreeSpace.smoothTotal() - minFreeSpace) * 0.2));
|
||||||
|
auto const targetBytes =
|
||||||
|
std::max<int64_t>(1, std::min<int64_t>(storageTargetBytes, smoothFreeSpace.smoothTotal() - minFreeSpace));
|
||||||
|
auto const targetRateRatio = std::min((storageQueue - targetBytes + springBytes) / (double)springBytes, 2.0);
|
||||||
|
auto const inputRate = smoothInputBytes.smoothRate();
|
||||||
|
if (targetRateRatio > 0 && inputRate > 0) {
|
||||||
|
return verySmoothDurableBytes.smoothRate() / (inputRate * targetRateRatio);
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TLogQueueInfo::TLogQueueInfo(UID id)
|
TLogQueueInfo::TLogQueueInfo(UID id)
|
||||||
: valid(false), id(id), smoothDurableBytes(SERVER_KNOBS->SMOOTHING_AMOUNT),
|
: valid(false), id(id), smoothDurableBytes(SERVER_KNOBS->SMOOTHING_AMOUNT),
|
||||||
smoothInputBytes(SERVER_KNOBS->SMOOTHING_AMOUNT), verySmoothDurableBytes(SERVER_KNOBS->SLOW_SMOOTHING_AMOUNT),
|
smoothInputBytes(SERVER_KNOBS->SMOOTHING_AMOUNT), verySmoothDurableBytes(SERVER_KNOBS->SLOW_SMOOTHING_AMOUNT),
|
||||||
|
@ -73,6 +73,9 @@ public:
|
|||||||
int64_t getDurabilityLag() const { return smoothLatestVersion.smoothTotal() - smoothDurableVersion.smoothTotal(); }
|
int64_t getDurabilityLag() const { return smoothLatestVersion.smoothTotal() - smoothDurableVersion.smoothTotal(); }
|
||||||
void update(StorageQueuingMetricsReply const&, Smoother& smoothTotalDurableBytes);
|
void update(StorageQueuingMetricsReply const&, Smoother& smoothTotalDurableBytes);
|
||||||
void addCommitCost(TransactionTagRef tagName, TransactionCommitCostEstimation const& cost);
|
void addCommitCost(TransactionTagRef tagName, TransactionCommitCostEstimation const& cost);
|
||||||
|
|
||||||
|
// Determine the ratio (limit / current throughput) for throttling based on write queue size
|
||||||
|
Optional<double> getWriteQueueSizeLimitRatio(int64_t storageSpringBytes, int64_t storageTargetBytes) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TLogQueueInfo {
|
struct TLogQueueInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user