Skip to content

Commit

Permalink
Use absolute value as lower bound for WriteAmpBasedRateLimiter's limit (
Browse files Browse the repository at this point in the history
#200)

Make it possible to use a huge value as `rate-bytes-per-sec` without losing the ability to adapt to normal pressure.

Signed-off-by: tabokie <xy.tao@outlook.com>
  • Loading branch information
tabokie authored Oct 22, 2020
1 parent cf6a77d commit 1a0b394
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions utilities/rate_limiters/write_amp_based_rate_limiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,8 @@ int64_t WriteAmpBasedRateLimiter::CalculateRefillBytesPerPeriod(
}

Status WriteAmpBasedRateLimiter::Tune() {
// computed rate limit will be larger than
// `max_bytes_per_sec_ / kAllowedRangeFactor`
const int kAllowedRangeFactor = 20;
// computed rate limit will be larger than `kMinBytesPerSec`
const int64_t kMinBytesPerSec = 10 * 1024 * 1024;
// high-priority bytes are padded to 20MB
const int64_t kHighBytesLower = 20 * 1024 * 1024;
// lower bound for write amplification estimation
Expand Down Expand Up @@ -323,7 +322,7 @@ Status WriteAmpBasedRateLimiter::Tune() {
(ratio + ratio_padding + ratio_delta_) *
std::max(highpri_bytes_sampler_.GetRecentValue(), kHighBytesLower) / 10;
new_bytes_per_sec = std::max(
max_bytes_per_sec_ / kAllowedRangeFactor,
kMinBytesPerSec,
std::min(new_bytes_per_sec,
max_bytes_per_sec_ - highpri_bytes_sampler_.GetRecentValue()));
if (new_bytes_per_sec != prev_bytes_per_sec) {
Expand Down

0 comments on commit 1a0b394

Please sign in to comment.