remove unused instance variable in GenericRateLimiter (#9484)
Summary: As reported in https://github.com/facebook/rocksdb/pull/2899#issuecomment-1001467021, `prev_num_drains_` is confusing as we never set it to nonzero. So this PR removes it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9484 Test Plan: `make check -j24` Reviewed By: hx235 Differential Revision: D33923203 Pulled By: ajkr fbshipit-source-id: 6277d50a198b90646583ee8094c2e6a1bbdadc7b
This commit is contained in:
parent
ed75dddc35
commit
272ce445d6
@ -91,8 +91,7 @@ GenericRateLimiter::GenericRateLimiter(
|
|||||||
available_bytes_(0),
|
available_bytes_(0),
|
||||||
rnd_((uint32_t)time(nullptr)),
|
rnd_((uint32_t)time(nullptr)),
|
||||||
wait_until_refill_pending_(false),
|
wait_until_refill_pending_(false),
|
||||||
num_drains_(0),
|
num_drains_(0) {
|
||||||
prev_num_drains_(0) {
|
|
||||||
RegisterOptions(&options_, &generic_rate_limiter_type_info);
|
RegisterOptions(&options_, &generic_rate_limiter_type_info);
|
||||||
for (int i = Env::IO_LOW; i < Env::IO_TOTAL; ++i) {
|
for (int i = Env::IO_LOW; i < Env::IO_TOTAL; ++i) {
|
||||||
total_requests_[i] = 0;
|
total_requests_[i] = 0;
|
||||||
@ -375,10 +374,9 @@ Status GenericRateLimiter::Tune() {
|
|||||||
std::chrono::microseconds(options_.refill_period_us);
|
std::chrono::microseconds(options_.refill_period_us);
|
||||||
// We tune every kRefillsPerTune intervals, so the overflow and division-by-
|
// We tune every kRefillsPerTune intervals, so the overflow and division-by-
|
||||||
// zero conditions should never happen.
|
// zero conditions should never happen.
|
||||||
assert(num_drains_ - prev_num_drains_ <= port::kMaxInt64 / 100);
|
assert(num_drains_ <= port::kMaxInt64 / 100);
|
||||||
assert(elapsed_intervals > 0);
|
assert(elapsed_intervals > 0);
|
||||||
int64_t drained_pct =
|
int64_t drained_pct = num_drains_ * 100 / elapsed_intervals;
|
||||||
(num_drains_ - prev_num_drains_) * 100 / elapsed_intervals;
|
|
||||||
|
|
||||||
int64_t prev_bytes_per_sec = GetBytesPerSecond();
|
int64_t prev_bytes_per_sec = GetBytesPerSecond();
|
||||||
int64_t new_bytes_per_sec;
|
int64_t new_bytes_per_sec;
|
||||||
@ -404,7 +402,7 @@ Status GenericRateLimiter::Tune() {
|
|||||||
if (new_bytes_per_sec != prev_bytes_per_sec) {
|
if (new_bytes_per_sec != prev_bytes_per_sec) {
|
||||||
SetBytesPerSecond(new_bytes_per_sec);
|
SetBytesPerSecond(new_bytes_per_sec);
|
||||||
}
|
}
|
||||||
num_drains_ = prev_num_drains_;
|
num_drains_ = 0;
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,6 @@ class GenericRateLimiter : public RateLimiter {
|
|||||||
bool wait_until_refill_pending_;
|
bool wait_until_refill_pending_;
|
||||||
|
|
||||||
int64_t num_drains_;
|
int64_t num_drains_;
|
||||||
int64_t prev_num_drains_;
|
|
||||||
std::chrono::microseconds tuned_time_;
|
std::chrono::microseconds tuned_time_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user