-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
nsqlookupd: enhance performance of /nodes #1099
nsqlookupd: enhance performance of /nodes #1099
Conversation
151e1c7
to
2e55bf2
Compare
I did notice the first version, it was pretty simple ... the latest version fails tests with:
|
@ploxiln Thanks for the review. I do not have test this locally and this is why i add WIP prefix to the title of the PR. I will fix this later today. |
eb5944b
to
fa8e39c
Compare
@ploxiln After apply the change. One of the clusters in our production reduce |
topicProducersMap[t] = s.ctx.nsqlookupd.DB.FindProducers("topic", t, "") | ||
} | ||
|
||
topicProducers := topicProducersMap[t] | ||
for _, tp := range topicProducers { | ||
if tp.peerInfo == p.peerInfo { | ||
tombstones[j] = tp.IsTombstoned(s.ctx.nsqlookupd.opts.TombstoneLifetime) |
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.
I think that adding a break
just after this line is an easy way to make this slightly faster
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.
Done.
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.
PTAL.
Looks good. It's funny that Anyway, not invasive, looks like a good little optimization. |
fa8e39c
to
d84a2d8
Compare
Still looks good to me :) |
@mreiferson PTAL. |
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.
LGTM, thanks!
Thanks for you @mreiferson and @ploxiln |
backport: nsqio#1099 See merge request nsq/nsq!34
Enhance performance for nodes api.
This PR will avoid an additional loop to produce the final result.
The cpu pprof shows that the map iterator of
ProducerMap2Slice
will consume most of the CPU cycle when requestingnodes
api.