@@ -79,12 +79,12 @@ DEFINE_int32(auto_cl_latency_fluctuation_correction_factor, 1,
7979 " when the server is overloaded." );
8080DEFINE_double (auto_cl_error_rate_punish_threshold, 0 ,
8181 " Threshold for error-rate-based punishment attenuation. "
82+ " Valid range: (0, 1). Values outside this range are ignored "
83+ " and original punishment logic is used. "
8284 " 0 (default): no effect, original punishment logic is used. "
83- " > 0 (e.g. 0.1): error rates below this threshold produce zero "
84- " punishment; above it the punishment scales linearly from 0 to "
85- " full strength. Only effective when auto_cl_enable_error_punish "
86- " is true. Example: 0.1 means error rates below 10%% are not "
87- " punished." );
85+ " e.g. 0.1: error rates below 10%% produce zero punishment; "
86+ " above it the punishment scales linearly from 0 to full strength. "
87+ " Only effective when auto_cl_enable_error_punish is true." );
8888
8989AutoConcurrencyLimiter::AutoConcurrencyLimiter ()
9090 : _max_concurrency(FLAGS_auto_cl_initial_max_concurrency)
@@ -245,12 +245,14 @@ void AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) {
245245 int32_t total_succ_req = _total_succ_req.load (butil::memory_order_relaxed);
246246 double failed_punish = _sw.total_failed_us * FLAGS_auto_cl_fail_punish_ratio;
247247
248- // Threshold-based attenuation: when auto_cl_error_rate_punish_threshold > 0,
249- // attenuate punishment based on error rate. Inspired by Sentinel's threshold-
250- // based circuit breaker: low error rates should not inflate avg_latency.
251- // Above threshold, punishment scales linearly from 0 to full strength.
252- // When threshold is 0 (default), this block is skipped entirely.
253- if (FLAGS_auto_cl_error_rate_punish_threshold > 0 && _sw.failed_count > 0 ) {
248+ // Threshold-based attenuation: when 0 < threshold < 1, attenuate punishment
249+ // based on error rate. Inspired by Sentinel's threshold-based circuit breaker:
250+ // low error rates should not inflate avg_latency. Above threshold, punishment
251+ // scales linearly from 0 to full strength.
252+ // Invalid values (<=0 or >=1) skip this block entirely, preserving original behavior.
253+ if (FLAGS_auto_cl_error_rate_punish_threshold > 0 &&
254+ FLAGS_auto_cl_error_rate_punish_threshold < 1.0 &&
255+ _sw.failed_count > 0 ) {
254256 double threshold = FLAGS_auto_cl_error_rate_punish_threshold;
255257 double error_rate = static_cast <double >(_sw.failed_count ) /
256258 (_sw.succ_count + _sw.failed_count );
0 commit comments