Commit 91cf5cb7 authored by Soultz's avatar Soultz

limit minimum value of max concurrency when all requests failed

parent f26de951
...@@ -189,7 +189,7 @@ bool AutoConcurrencyLimiter::AddSample(int error_code, ...@@ -189,7 +189,7 @@ bool AutoConcurrencyLimiter::AddSample(int error_code,
UpdateMaxConcurrency(sampling_time_us); UpdateMaxConcurrency(sampling_time_us);
} else { } else {
// All request failed // All request failed
_max_concurrency /= 2; AdjustMaxConcurrency(_max_concurrency / 2);
} }
ResetSampleWindow(sampling_time_us); ResetSampleWindow(sampling_time_us);
return true; return true;
...@@ -222,6 +222,13 @@ void AutoConcurrencyLimiter::UpdateQps(double qps) { ...@@ -222,6 +222,13 @@ void AutoConcurrencyLimiter::UpdateQps(double qps) {
} }
} }
void AutoConcurrencyLimiter::AdjustMaxConcurrency(int next_max_concurrency) {
next_max_concurrency = std::max(bthread::FLAGS_bthread_concurrency, next_max_concurrency);
if (next_max_concurrency != _max_concurrency) {
_max_concurrency = next_max_concurrency;
}
}
void AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) { void AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) {
int32_t total_succ_req = _total_succ_req.load(butil::memory_order_relaxed); int32_t total_succ_req = _total_succ_req.load(butil::memory_order_relaxed);
double failed_punish = _sw.total_failed_us * FLAGS_auto_cl_fail_punish_ratio; double failed_punish = _sw.total_failed_us * FLAGS_auto_cl_fail_punish_ratio;
...@@ -253,10 +260,7 @@ void AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) { ...@@ -253,10 +260,7 @@ void AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) {
_min_latency_us * _ema_max_qps / 1000000 * (1 + _explore_ratio); _min_latency_us * _ema_max_qps / 1000000 * (1 + _explore_ratio);
} }
next_max_concurrency = std::max(bthread::FLAGS_bthread_concurrency, next_max_concurrency); AdjustMaxConcurrency(next_max_concurrency);
if (next_max_concurrency != _max_concurrency) {
_max_concurrency = next_max_concurrency;
}
} }
} // namespace policy } // namespace policy
......
...@@ -62,6 +62,8 @@ private: ...@@ -62,6 +62,8 @@ private:
void UpdateMinLatency(int64_t latency_us); void UpdateMinLatency(int64_t latency_us);
void UpdateQps(double qps); void UpdateQps(double qps);
void AdjustMaxConcurrency(int next_max_concurrency);
// modified per sample-window or more // modified per sample-window or more
int _max_concurrency; int _max_concurrency;
int64_t _remeasure_start_us; int64_t _remeasure_start_us;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment