-
Notifications
You must be signed in to change notification settings - Fork 18
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Filtered-out log.Level lines still cost #14
Comments
@bboreham I wouldn't say you are holding it wrong, but there may be one tweak to improve it. More on that later. First, let me say up front, that the
If you just want better performance, and you don't need optimal performance, then there is one thing you can do, though. You noted that Playground link for the below code: https://play.golang.org/p/Z3nf1G9jvR0
Note that you cannot use |
This saves a lot of work walking the stack to find the caller, and a bit more to format the timestamp. Recommended at go-kit/log#14 (comment) Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Thank you, swapping the filter to last does indeed take out the bulk of the overhead. Would it be better to put the filter last in the example? Lines 6 to 8 in 71fa7d7
I found that, because the go-kit |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I noticed a portion of our CPU was going into
level.Debug(...).Log()
lines, although that level wasn't enabled.I think what is happening is the
Log()
call goes intocontext.Log()
first, which callsbindValues
which is the expensive part, callingruntime.Caller
, formatting a timestamp, etc., then after that it goes tolevel.Log()
which discards everything.I looked around but didn't find any previous debate on this point. Am I holding it wrong? Is this expected?
Since we are using a wrapper, something like go-kit/kit#322 would let us work around the problem by checking before doing the work, but that was rejected.
The text was updated successfully, but these errors were encountered: