-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ftr: bitmap in router chain #708
Conversation
Thanks Alex for the review comments. I will take a look tomorrow. |
cluster/router/chain/chain.go
Outdated
// buildCache builds address cache with the new invokers for all poolable routers. | ||
func (c *RouterChain) buildCache() { | ||
invokers := c.copyInvokers() | ||
if invokers == nil || len(c.invokers) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls delete the condition len(c.invokers) == 0
because u have check it in c.copyInvokers().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still necessary, since the copied invokers will be null if the original invoker to be copied is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the conflicts pls, thanks.
Codecov Report
@@ Coverage Diff @@
## develop #708 +/- ##
===========================================
- Coverage 64.08% 63.73% -0.36%
===========================================
Files 239 239
Lines 12753 12719 -34
===========================================
- Hits 8173 8106 -67
- Misses 3796 3834 +38
+ Partials 784 779 -5
Continue to review full report at Codecov.
|
|
||
c.count++ | ||
now := time.Now() | ||
if c.count >= countThreshold && now.Sub(c.last) >= timeThreshold { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data from registry is changed once, it will not notify to c.notify.
And it will build cache when it is timeout or receive notify channel. The worst situation is that it cannot build cache after 5 seconds.
//cluster/router/chain/chain.go:127
for {
ticker := time.NewTicker(timeInterval)
select {
case <-ticker.C:
c.buildCache()
case <-c.notify:
c.buildCache()
}
}
It can't be build cache as soon as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is expected.
Introduce roaring bitmap in router chain. By doing this, we can avoid iterating every invoker in Route as much as possible so that we could reduce consuming both CPU and memory. At the same time, by passing the pre-built address cache along the router chain, we can keep router's implementation lock-free at the same time.