-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
perf: Replace channel check with atomic bool in tailer.send() #12976
Conversation
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.
Would it make sense to remove closeChan
altogether? I see it's used in a few other select
statements that we can't get rid of, but it would keep us from signaling closed
in two different ways in the same file.
Nevermind. On closer look, those other usages rely on the close chan to interrupt selects blocking
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 !
For next time, in your PR you can use benchstat it gives a much better output.
What this PR does / why we need it:
send()
but retained thecloseChan
to signal the other parts of the tailer to shut down ASAP, otherwise we'd need to check the bool periodically using (for example)time.After
.Benchmark before thte change, using select-default:
Benchmark after the change, using atomic bool:
So this small change is nearly 10x faster and therefore would save ~18-20 cores worth of CPU time in our ops cluster.