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
25744b7f
Commit
25744b7f
authored
Jul 26, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix codestyle
parent
67b3f54e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
gradient_concurrency_limiter.cpp
src/brpc/policy/gradient_concurrency_limiter.cpp
+4
-5
gradient_concurrency_limiter.h
src/brpc/policy/gradient_concurrency_limiter.h
+1
-1
No files found.
src/brpc/policy/gradient_concurrency_limiter.cpp
View file @
25744b7f
...
...
@@ -119,8 +119,7 @@ void GradientConcurrencyLimiter::OnResponded(int error_code,
last_sampling_time_us
,
now_time_us
,
butil
::
memory_order_relaxed
);
if
(
sample_this_call
)
{
int32_t
max_concurrency
=
AddSample
(
error_code
,
latency_us
,
now_time_us
);
int32_t
max_concurrency
=
AddSample
(
error_code
,
latency_us
,
now_time_us
);
if
(
max_concurrency
!=
0
)
{
LOG
(
INFO
)
<<
"MaxConcurrency updated by gradient limiter:"
...
...
@@ -132,13 +131,13 @@ void GradientConcurrencyLimiter::OnResponded(int error_code,
int
GradientConcurrencyLimiter
::
NextResetCount
()
{
int
max_reset_count
=
FLAGS_gradient_cl_reset_count
;
return
rand
()
%
(
max_reset_count
/
2
)
+
max_reset_count
/
2
;
return
butil
::
fast_rand_less_than
(
max_reset_count
/
2
)
+
max_reset_count
/
2
;
}
int32_t
GradientConcurrencyLimiter
::
AddSample
(
int
error_code
,
int64_t
latency_us
,
int64_t
sampling_time_us
)
{
BAIDU_SCOPED_LOCK
(
_sw_mutex
);
std
::
unique_lock
<
butil
::
Mutex
>
lock_guard
(
_sw_mutex
);
if
(
_sw
.
start_time_us
==
0
)
{
_sw
.
start_time_us
=
sampling_time_us
;
}
...
...
@@ -219,7 +218,7 @@ int32_t GradientConcurrencyLimiter::UpdateMaxConcurrency(
}
int32_t
next_max_concurrency
=
std
::
ceil
(
_ema_qps
*
_min_latency_us
/
1000
.0
/
100
0
);
std
::
ceil
(
_ema_qps
*
_min_latency_us
/
1000
000.
0
);
if
(
--
_reset_count
==
0
)
{
_reset_count
=
NextResetCount
();
if
(
current_concurrency
>=
max_concurrency
-
2
)
{
...
...
src/brpc/policy/gradient_concurrency_limiter.h
View file @
25744b7f
...
...
@@ -68,7 +68,7 @@ private:
int
_reset_count
;
int64_t
_min_latency_us
;
const
double
_smooth
;
int32_t
_ema_qps
;
double
_ema_qps
;
butil
::
Mutex
_sw_mutex
;
bvar
::
PassiveStatus
<
int32_t
>
_max_concurrency_bvar
;
butil
::
atomic
<
int64_t
>
BAIDU_CACHELINE_ALIGNMENT
_last_sampling_time_us
;
...
...
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