-
Notifications
You must be signed in to change notification settings - Fork 226
Comparing changes
Open a pull request
base repository: kubernetes/klog
base: v2.80.1
head repository: kubernetes/klog
compare: v2.90.0
- 16 commits
- 18 files changed
- 2 contributors
Commits on Oct 27, 2022
-
klog: benchmark the overhead when logging is off
Most of the log calls in a program do not emit log data, but the parameters for the call need to be prepared anyway, which causes overhead.
Configuration menu - View commit details
-
Copy full SHA for f08fd26 - Browse repository at this point
Copy the full SHA f08fd26View commit details
Commits on Oct 28, 2022
-
Merge pull request #355 from pohly/call-overhead-benchmarks
klog: benchmark the overhead when logging is off
Configuration menu - View commit details
-
Copy full SHA for 9ae4992 - Browse repository at this point
Copy the full SHA 9ae4992View commit details
Commits on Jan 19, 2023
-
klogr: avoid calling Info/Error/Enabled through auto-generated code
These functions get called for a pointer because that is what we use to implement the LogSink interface. The variant of these functions which take a value instead of a pointer was never used, so providing directly what is needed instead of relying on the compiler to generate that is more efficient (less code, avoids one extra callstack entry at runtime). The With* functions must continue to take a value because they need to modify that copy.
Configuration menu - View commit details
-
Copy full SHA for d20ee72 - Browse repository at this point
Copy the full SHA d20ee72View commit details -
test: move InitKlog into tests
This makes it possible to use test.Output inside packages that have other tests.
Configuration menu - View commit details
-
Copy full SHA for c34db96 - Browse repository at this point
Copy the full SHA c34db96View commit details -
When klogr called V(), it didn't pass the callstack offset, which broke evaluation of the -vmodule patterns. A new VWithOffset klog API is needed to fix this. A unit test for this will follow.
Configuration menu - View commit details
-
Copy full SHA for 125ecfe - Browse repository at this point
Copy the full SHA 125ecfeView commit details -
Besides sharing code, it's also better in two regards: - restores state after test - avoids triple printing of errors
Configuration menu - View commit details
-
Copy full SHA for 34a9807 - Browse repository at this point
Copy the full SHA 34a9807View commit details -
textlogger: fix vmodule support
When Logger.Info called Enabled, the wrong number of stack frames were skipped. A unit test for this will follow.
Configuration menu - View commit details
-
Copy full SHA for 70aa795 - Browse repository at this point
Copy the full SHA 70aa795View commit details -
move output tests into packages
Previously it was necessary to enter the "examples" module to run output tests for code in the main module. Now "go test ./..." at the root or in individual directories also runs these tests.
Configuration menu - View commit details
-
Copy full SHA for f833abb - Browse repository at this point
Copy the full SHA f833abbView commit details -
use output test cases also for benchmarking
So far, the output tests were only used for correctness checking. But they cover a variety of scenarios for which there were no benchmarks, therefore it makes sense to also use them for that.
Configuration menu - View commit details
-
Copy full SHA for 757e6bb - Browse repository at this point
Copy the full SHA 757e6bbView commit details -
test: unit tests for vmodule support
Text logger and the two klogr implementations both got this wrong.
Configuration menu - View commit details
-
Copy full SHA for ff4f80f - Browse repository at this point
Copy the full SHA ff4f80fView commit details -
This simplifies the code. Instead of different instances, the package now maintains a global pool. This makes the text logger struct a bit smaller and thus cheaper to copy in the With* functions. Performance is about the same as before: name old time/op new time/op delta Header-36 1.68µs ± 7% 1.62µs ± 6% ~ (p=0.246 n=5+5) HeaderWithDir-36 1.63µs ± 6% 1.59µs ± 6% ~ (p=0.690 n=5+5) name old alloc/op new alloc/op delta Header-36 216B ± 0% 216B ± 0% ~ (all equal) HeaderWithDir-36 216B ± 0% 216B ± 0% ~ (all equal) name old allocs/op new allocs/op delta Header-36 2.00 ± 0% 2.00 ± 0% ~ (all equal) HeaderWithDir-36 2.00 ± 0% 2.00 ± 0% ~ (all equal) The text logger didn't actually return the buffer. Now it does.
Configuration menu - View commit details
-
Copy full SHA for 1a1367c - Browse repository at this point
Copy the full SHA 1a1367cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9674cae - Browse repository at this point
Copy the full SHA 9674caeView commit details -
serialize: combine merging and formatting
This avoids one memory allocation (for the intermediate slice), copying and loops.
Configuration menu - View commit details
-
Copy full SHA for 926ab6d - Browse repository at this point
Copy the full SHA 926ab6dView commit details -
KObj: optimize string concatenation
Using a strings.Builder reduces the number of allocations: name old time/op new time/op delta KlogOutput/KObjSlice_okay-36 15.2µs ± 5% 14.8µs ± 4% ~ (p=0.151 n=5+5) KlogOutput/KObjSlice_nil_entry-36 14.4µs ± 5% 13.6µs ± 3% -5.25% (p=0.032 n=5+5) KlogOutput/KObj-36 13.5µs ± 8% 13.5µs ± 6% ~ (p=0.841 n=5+5) KlogOutput/KObjSlice_ints-36 15.3µs ± 5% 15.2µs ± 4% ~ (p=0.841 n=5+5) KlogOutput/KObjSlice_nil_arg-36 12.8µs ± 2% 12.8µs ± 6% ~ (p=0.841 n=5+5) KlogOutput/KObjSlice_int_arg-36 14.1µs ± 4% 13.8µs ± 3% ~ (p=0.310 n=5+5) KlogOutput/KObjs-36 14.1µs ± 8% 13.6µs ± 8% ~ (p=0.690 n=5+5) name old alloc/op new alloc/op delta KlogOutput/KObjSlice_okay-36 2.89kB ± 0% 2.82kB ± 0% -2.23% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_entry-36 2.65kB ± 0% 2.62kB ± 0% ~ (p=0.079 n=4+5) KlogOutput/KObj-36 2.50kB ± 0% 2.47kB ± 0% -1.30% (p=0.000 n=4+5) KlogOutput/KObjSlice_ints-36 2.90kB ± 0% 2.90kB ± 0% ~ (p=1.000 n=5+5) KlogOutput/KObjSlice_nil_arg-36 2.41kB ± 0% 2.41kB ± 0% ~ (all equal) KlogOutput/KObjSlice_int_arg-36 2.67kB ± 0% 2.67kB ± 0% ~ (all equal) KlogOutput/KObjs-36 2.72kB ± 0% 2.65kB ± 0% -2.38% (p=0.008 n=5+5) name old allocs/op new allocs/op delta KlogOutput/KObjSlice_okay-36 46.0 ± 0% 42.0 ± 0% -8.70% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_entry-36 40.0 ± 0% 38.0 ± 0% -5.00% (p=0.008 n=5+5) KlogOutput/KObj-36 36.0 ± 0% 34.0 ± 0% -5.56% (p=0.008 n=5+5) KlogOutput/KObjSlice_ints-36 39.0 ± 0% 39.0 ± 0% ~ (all equal) KlogOutput/KObjSlice_nil_arg-36 35.0 ± 0% 35.0 ± 0% ~ (all equal) KlogOutput/KObjSlice_int_arg-36 37.0 ± 0% 37.0 ± 0% ~ (all equal) KlogOutput/KObjs-36 42.0 ± 0% 38.0 ± 0% -9.52% (p=0.008 n=5+5)
Configuration menu - View commit details
-
Copy full SHA for a1638bf - Browse repository at this point
Copy the full SHA a1638bfView commit details -
KObj, KObjSlice: format more efficiently as text
The klog text format avoids some string allocation by calling WriteText instead of String when encountering such values. A positive side effect is that KObjSlice now gets logged like KObjs, i.e. pods=[namespace1/name1 namespace2/name2] Previously, it was written as a quoted string. To achieve the best performance, WriteText is passed a bytes.Buffer pointer instead of a io.Writer. This avoids an interface allocation for the parameter and provides access to the underlying methods. Benchmarks involving these types benefit while other are the same as before: name old time/op new time/op delta KlogOutput/KObj-36 12.7µs ±10% 13.1µs ± 1% ~ (p=0.151 n=5+5) KlogOutput/KObjs-36 13.4µs ± 7% 14.0µs ± 5% ~ (p=0.310 n=5+5) KlogOutput/KObjSlice_okay-36 14.8µs ± 4% 13.0µs ± 3% -12.33% (p=0.008 n=5+5) KlogOutput/KObjSlice_int_arg-36 14.0µs ± 6% 12.3µs ±10% -12.60% (p=0.008 n=5+5) KlogOutput/KObjSlice_ints-36 15.5µs ± 4% 12.8µs ± 6% -17.85% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_entry-36 14.2µs ±13% 12.6µs ± 3% -11.39% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_arg-36 12.6µs ± 6% 12.9µs ± 3% ~ (p=0.690 n=5+5) name old alloc/op new alloc/op delta KlogOutput/KObj-36 2.47kB ± 0% 2.41kB ± 0% -2.29% (p=0.008 n=5+5) KlogOutput/KObjs-36 2.65kB ± 0% 2.65kB ± 0% ~ (all equal) KlogOutput/KObjSlice_okay-36 2.82kB ± 0% 2.45kB ± 0% -13.37% (p=0.008 n=5+5) KlogOutput/KObjSlice_int_arg-36 2.67kB ± 0% 2.45kB ± 0% -8.42% (p=0.029 n=4+4) KlogOutput/KObjSlice_ints-36 2.90kB ± 0% 2.49kB ± 0% -14.37% (p=0.000 n=4+5) KlogOutput/KObjSlice_nil_entry-36 2.62kB ± 0% 2.43kB ± 0% -7.34% (p=0.000 n=4+5) KlogOutput/KObjSlice_nil_arg-36 2.41kB ± 0% 2.40kB ± 0% -0.66% (p=0.016 n=5+4) name old allocs/op new allocs/op delta KlogOutput/KObj-36 34.0 ± 0% 32.0 ± 0% -5.88% (p=0.008 n=5+5) KlogOutput/KObjs-36 38.0 ± 0% 38.0 ± 0% ~ (all equal) KlogOutput/KObjSlice_okay-36 42.0 ± 0% 32.0 ± 0% -23.81% (p=0.008 n=5+5) KlogOutput/KObjSlice_int_arg-36 37.0 ± 0% 32.0 ± 0% -13.51% (p=0.008 n=5+5) KlogOutput/KObjSlice_ints-36 39.0 ± 0% 33.0 ± 0% -15.38% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_entry-36 38.0 ± 0% 32.0 ± 0% -15.79% (p=0.008 n=5+5) KlogOutput/KObjSlice_nil_arg-36 35.0 ± 0% 32.0 ± 0% -8.57% (p=0.008 n=5+5)
Configuration menu - View commit details
-
Copy full SHA for 8eadf2c - Browse repository at this point
Copy the full SHA 8eadf2cView commit details -
github: bump golangci-lint image version
It looks like golangci-lint comes with a fixed version of Go, one which is too old for the code: level=error msg="Running error: gofmt: analysis skipped: errors in package: [/go/src/k8s.io/klog/test/output.go:846:22: Discard not declared by package io /go/src/k8s.io/klog/test/output.go:864:40: Discard not declared by package io /go/src/k8s.io/klog/test/output.go:876:35: Discard not declared by package io]" io.Discard was introduced in Go 1.16, using it should be fine and is reflected in our Go version test matrix (>= 1.17).
Configuration menu - View commit details
-
Copy full SHA for 1025055 - Browse repository at this point
Copy the full SHA 1025055View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v2.80.1...v2.90.0