Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
362c5d02
Commit
362c5d02
authored
Aug 14, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize the logic to re-measure min_latency
parent
fe4f21fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
auto_concurrency_limiter.cpp
src/brpc/policy/auto_concurrency_limiter.cpp
+11
-10
auto_concurrency_limiter.h
src/brpc/policy/auto_concurrency_limiter.h
+0
-1
No files found.
src/brpc/policy/auto_concurrency_limiter.cpp
View file @
362c5d02
...
...
@@ -57,7 +57,6 @@ static int32_t cast_max_concurrency(void* arg) {
AutoConcurrencyLimiter
::
AutoConcurrencyLimiter
()
:
_remeasure_start_us
(
NextResetTime
(
butil
::
gettimeofday_us
()))
,
_remeasure_end_us
(
0
)
,
_reset_latency_us
(
0
)
,
_min_latency_us
(
-
1
)
,
_ema_peak_qps
(
-
1
)
...
...
@@ -217,22 +216,24 @@ int32_t AutoConcurrencyLimiter::UpdateMaxConcurrency(int64_t sampling_time_us) {
UpdateMinLatency
(
avg_latency
);
UpdateQps
(
total_succ_req
,
sampling_time_us
);
if
(
_remeasure_end_us
>
sampling_time_us
&&
_reset_latency_us
>
0
)
{
if
(
_reset_latency_us
<
sampling_time_us
)
{
_min_latency_us
=
-
1
;
_reset_latency_us
=
0
;
}
// Waiting for the current concurrent decline
if
(
_reset_latency_us
>
sampling_time_us
)
{
return
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
;
}
int
next_max_concurrency
=
0
;
// Remeasure min_latency at regular intervals
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
;
_remeasure_end_us
=
_reset_latency_us
+
2
*
FLAGS_auto_cl_sample_window_size_ms
*
1000
;
next_max_concurrency
=
_max_concurrency
/
2
;
LOG
(
INFO
)
<<
"Prepare"
<<
_max_concurrency
;
}
else
{
int32_t
noload_concurrency
=
std
::
ceil
(
_min_latency_us
*
_ema_peak_qps
/
1000000
);
...
...
src/brpc/policy/auto_concurrency_limiter.h
View file @
362c5d02
...
...
@@ -63,7 +63,6 @@ private:
SampleWindow
_sw
;
int64_t
_remeasure_start_us
;
int64_t
_remeasure_end_us
;
int64_t
_reset_latency_us
;
int64_t
_min_latency_us
;
double
_ema_peak_qps
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment