Commit 362c5d02 authored by TousakaRin's avatar TousakaRin

Optimize the logic to re-measure min_latency

parent fe4f21fa
...@@ -57,7 +57,6 @@ static int32_t cast_max_concurrency(void* arg) { ...@@ -57,7 +57,6 @@ static int32_t cast_max_concurrency(void* arg) {
AutoConcurrencyLimiter::AutoConcurrencyLimiter() AutoConcurrencyLimiter::AutoConcurrencyLimiter()
: _remeasure_start_us(NextResetTime(butil::gettimeofday_us())) : _remeasure_start_us(NextResetTime(butil::gettimeofday_us()))
, _remeasure_end_us(0)
, _reset_latency_us(0) , _reset_latency_us(0)
, _min_latency_us(-1) , _min_latency_us(-1)
, _ema_peak_qps(-1) , _ema_peak_qps(-1)
...@@ -217,22 +216,24 @@ int32_t AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) { ...@@ -217,22 +216,24 @@ int32_t AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) {
UpdateMinLatency(avg_latency); UpdateMinLatency(avg_latency);
UpdateQps(total_succ_req, sampling_time_us); UpdateQps(total_succ_req, sampling_time_us);
if (_remeasure_end_us > sampling_time_us && _reset_latency_us > 0) { // Waiting for the current concurrent decline
if (_reset_latency_us < sampling_time_us) { if (_reset_latency_us > sampling_time_us) {
_min_latency_us = -1; return 0;
_reset_latency_us = 0; }
} // Remeasure min_latency when concurrency has dropped to low load
if (_reset_latency_us > 0 && _reset_latency_us < sampling_time_us) {
_min_latency_us = -1;
_reset_latency_us = 0;
_remeasure_start_us = NextResetTime(sampling_time_us);
return 0; return 0;
} }
int next_max_concurrency = 0; int next_max_concurrency = 0;
// Remeasure min_latency at regular intervals
if (_remeasure_start_us <= sampling_time_us) { if (_remeasure_start_us <= sampling_time_us) {
_min_latency_us = -1;
_remeasure_start_us = NextResetTime(sampling_time_us);
_reset_latency_us = sampling_time_us + avg_latency; _reset_latency_us = sampling_time_us + avg_latency;
_remeasure_end_us = _reset_latency_us +
2 * FLAGS_auto_cl_sample_window_size_ms * 1000;
next_max_concurrency = _max_concurrency / 2; next_max_concurrency = _max_concurrency / 2;
LOG(INFO) << "Prepare" << _max_concurrency;
} else { } else {
int32_t noload_concurrency = int32_t noload_concurrency =
std::ceil(_min_latency_us * _ema_peak_qps / 1000000); std::ceil(_min_latency_us * _ema_peak_qps / 1000000);
......
...@@ -63,7 +63,6 @@ private: ...@@ -63,7 +63,6 @@ private:
SampleWindow _sw; SampleWindow _sw;
int64_t _remeasure_start_us; int64_t _remeasure_start_us;
int64_t _remeasure_end_us;
int64_t _reset_latency_us; int64_t _reset_latency_us;
int64_t _min_latency_us; int64_t _min_latency_us;
double _ema_peak_qps; double _ema_peak_qps;
......
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