You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ww...@apache.org on 2023/02/06 01:58:51 UTC
[brpc] branch master updated: In extreme cases, the average latency may be greater than requested timeout, allow currency_concurrency is 1 ensures the average latency can be obtained renew.
This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 4eee48c9 In extreme cases, the average latency may be greater than requested timeout, allow currency_concurrency is 1 ensures the average latency can be obtained renew.
new 02ec31d6 Merge pull request #2106 from yanglimingcn/feature/timeout_concurrency_limiter_add_max_concurrency
4eee48c9 is described below
commit 4eee48c94944f70eaa02fd21df2a40aef576e1ae
Author: Yang Liming <li...@139.com>
AuthorDate: Tue Jan 31 19:28:45 2023 +0800
In extreme cases, the average latency may be greater than requested timeout, allow currency_concurrency is 1 ensures the average latency can be obtained renew.
---
src/brpc/policy/timeout_concurrency_limiter.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/brpc/policy/timeout_concurrency_limiter.cpp b/src/brpc/policy/timeout_concurrency_limiter.cpp
index 94ee8df4..27c608e5 100644
--- a/src/brpc/policy/timeout_concurrency_limiter.cpp
+++ b/src/brpc/policy/timeout_concurrency_limiter.cpp
@@ -67,8 +67,12 @@ bool TimeoutConcurrencyLimiter::OnRequested(int current_concurrency,
if (cntl != nullptr && cntl->timeout_ms() != UNSET_MAGIC_NUM) {
timeout_ms = cntl->timeout_ms();
}
- return current_concurrency <= FLAGS_timeout_cl_max_concurrency &&
- _avg_latency_us < timeout_ms * 1000;
+ // In extreme cases, the average latency may be greater than requested
+ // timeout, allow currency_concurrency is 1 ensures the average latency can
+ // be obtained renew.
+ return current_concurrency == 1 ||
+ (current_concurrency <= FLAGS_timeout_cl_max_concurrency &&
+ _avg_latency_us < timeout_ms * 1000);
}
void TimeoutConcurrencyLimiter::OnResponded(int error_code,
@@ -137,7 +141,7 @@ bool TimeoutConcurrencyLimiter::AddSample(int error_code, int64_t latency_us,
UpdateAvgLatency();
} else {
// All request failed
- AdjustAvgLatency(_avg_latency_us / 2);
+ AdjustAvgLatency(_avg_latency_us * 2);
}
ResetSampleWindow(sampling_time_us);
return true;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org