-
Notifications
You must be signed in to change notification settings - Fork 78
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
Rearch for performance: BREAKING CHANGES #42
Merged
Merged
Commits on Apr 22, 2021
-
Make the benchmark not inline ther impl
In real code, the definition of the Logger would be far away from the logging call-sites. The benchmark now forces the compiler to NOT inline, even though it could. It also now tests logr.Discard() and funcr.
Configuration menu - View commit details
-
Copy full SHA for 2a44646 - Browse repository at this point
Copy the full SHA 2a44646View commit details
Commits on May 16, 2021
-
Convert Logger from an interfact to a concrete type that calls out to a LogSink interface. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! THIS IS A BREAKING CHANGE !! !! !! !! Most end-users just need to recompile. !! !! !! !! Logging implementations need to make code changes. !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Before: ``` $ go test -bench='.' ./benchmark/ goos: linux goarch: amd64 pkg: github.com/go-logr/logr/benchmark cpu: Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz BenchmarkInfoOneArg-6 3013077 400.9 ns/op BenchmarkInfoSeveralArgs-6 1162088 1039 ns/op BenchmarkV0Info-6 754347 1418 ns/op BenchmarkV9Info-6 4605950 267.8 ns/op BenchmarkError-6 935028 1135 ns/op BenchmarkWithValues-6 5127631 232.5 ns/op BenchmarkWithName-6 12850569 106.5 ns/op ``` After: ``` $ go test -bench='.' ./benchmark/ goos: linux goarch: amd64 pkg: github.com/go-logr/logr/benchmark cpu: Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz BenchmarkInfoOneArg-6 2465788 475.7 ns/op BenchmarkInfoSeveralArgs-6 893026 1226 ns/op BenchmarkV0Info-6 817473 1250 ns/op BenchmarkV9Info-6 8595180 155.1 ns/op BenchmarkError-6 1000000 1371 ns/op BenchmarkWithValues-6 3902214 292.0 ns/op BenchmarkWithName-6 11271037 106.6 ns/op ``` Logs that actually write are dominated by the cost of preparing the message. Logs which do not write (e.g. `V(9)`) are faster here (thog glog raw is much faster still). The main difference is the variadic slice setup. This is a candidate for Go to optimize - it now knows that the args are only used inside the conditional (`Enabled()`), and when that path is not executed, it can elide that work.
Configuration menu - View commit details
-
Copy full SHA for bb231ff - Browse repository at this point
Copy the full SHA bb231ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6987102 - Browse repository at this point
Copy the full SHA 6987102View commit details -
Configuration menu - View commit details
-
Copy full SHA for 000e78e - Browse repository at this point
Copy the full SHA 000e78eView commit details -
This allows logr to pass params about internal stuff (such as the number of call frames it adds) to LogSink implementations.
Configuration menu - View commit details
-
Copy full SHA for 19480e9 - Browse repository at this point
Copy the full SHA 19480e9View commit details -
Remove deprecated back-compat things
DiscardLogger became a LogSink, so leaving that as a type was only needed for NullLogger. NullLogger can be completely replaced with Discard(). InfoLogger is vestigial and since this is a breaking change anyway, let's kill it off. Not that Logger is a type, we do not need WithCallDepth() as a standalone anymore.
Configuration menu - View commit details
-
Copy full SHA for 68c541a - Browse repository at this point
Copy the full SHA 68c541aView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.