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
074e0315
Unverified
Commit
074e0315
authored
Jan 21, 2020
by
Ge Jun
Committed by
GitHub
Jan 21, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #999 from lorinlee/typos
fix some typos
parents
a6298c1d
eb5528c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
locality_aware_load_balancer.cpp
src/brpc/policy/locality_aware_load_balancer.cpp
+7
-7
locality_aware_load_balancer.h
src/brpc/policy/locality_aware_load_balancer.h
+1
-1
No files found.
src/brpc/policy/locality_aware_load_balancer.cpp
View file @
074e0315
...
...
@@ -82,13 +82,13 @@ bool LocalityAwareLoadBalancer::Add(Servers& bg, const Servers& fg,
// Push the weight structure into the tree. Notice that we also need
// a left_weight entry to store weight sum of all left nodes so that
// the load balancing by weights can be done in O(logN) complexi
ci
ty.
// the load balancing by weights can be done in O(logN) complexity.
ServerInfo
info
=
{
id
,
lb
->
PushLeft
(),
new
Weight
(
initial_weight
)
};
bg
.
weight_tree
.
push_back
(
info
);
// The weight structure may already have initial weight. Add the weight
// to left_weight entries of all parent nodes and _total. The time
// complexi
ci
ty is strictly O(logN) because the tree is complete.
// complexity is strictly O(logN) because the tree is complete.
const
int64_t
diff
=
info
.
weight
->
volatile_value
();
if
(
diff
)
{
bg
.
UpdateParentWeights
(
diff
,
index
);
...
...
@@ -120,7 +120,7 @@ bool LocalityAwareLoadBalancer::Remove(
// it retries, as if this range of weight is removed.
const
int64_t
rm_weight
=
w
->
Disable
();
if
(
index
+
1
==
bg
.
weight_tree
.
size
())
{
// last node. Removing is ea
is
er.
// last node. Removing is ea
si
er.
bg
.
weight_tree
.
pop_back
();
if
(
rm_weight
)
{
// The first buffer. Remove the weight from parents to disable
...
...
@@ -151,10 +151,10 @@ bool LocalityAwareLoadBalancer::Remove(
// However this process is not atomic. The foreground buffer still
// sees w2 as last node and it may change the weight during the
// process. To solve this problem, we atomically reset the weight
// and remember the pre
iv
ous index (back()) in _old_index. Later
// and remember the pre
vi
ous index (back()) in _old_index. Later
// change to weight will add the diff to _old_diff_sum if _old_index
// matches the index which SelectServer is from. In this way we
// know the weight diff from foreground before we later
ly
modify it.
// know the weight diff from foreground before we later modify it.
const
int64_t
add_weight
=
w2
->
MarkOld
(
bg
.
weight_tree
.
size
());
// Add the weight diff to parent nodes of node `index'. Notice
...
...
@@ -288,7 +288,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out)
// Locate a weight range in the tree. This is obviously not atomic and
// left-weights / total / weight-of-the-node may not be consistent. But
// this is what we have to pay to gain more parallism.
// this is what we have to pay to gain more parall
el
ism.
const
ServerInfo
&
info
=
s
->
weight_tree
[
index
];
const
int64_t
left
=
info
.
left
->
load
(
butil
::
memory_order_relaxed
);
if
(
dice
<
left
)
{
...
...
@@ -396,7 +396,7 @@ int64_t LocalityAwareLoadBalancer::Weight::Update(
// Accumulate into the last entry so that errors always decrease
// the overall QPS and latency.
// Note that the latency used is linearly mixed from the real latency
// (of an erro
r
ous call) and the timeout, so that errors that are more
// (of an erro
ne
ous call) and the timeout, so that errors that are more
// unlikely to be solved by later retries are punished more.
// Examples:
// max_retry=0: always use timeout
...
...
src/brpc/policy/locality_aware_load_balancer.h
View file @
074e0315
...
...
@@ -37,7 +37,7 @@ DECLARE_double(punish_inflight_ratio);
// Locality-aware is an iterative algorithm to send requests to servers which
// have lowest expected latencies. Read docs/cn/lalb.md to get a peek at the
// algorithm. The implemention is complex.
// algorithm. The implement
at
ion is complex.
class
LocalityAwareLoadBalancer
:
public
LoadBalancer
{
public
:
LocalityAwareLoadBalancer
();
...
...
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