Comments (1)
https://github.com/go-logr/zapr/compare/master...pohly:stream-values?expand=1 implements this, but didn't provide a clear advantage when testing with k/k/test/integration/logs/benchmark:
$ benchstat zapr-master-contextual.log zapr-stream-2-contextual.log
name old msgs/s new msgs/s delta
Encoding/v3/kind-worker-kubelet/JSON-36 396k ± 4% 399k ± 0% ~ (p=0.690 n=5+5)
Encoding/v3/kube-apiserver/JSON-36 207k ± 2% 249k ± 2% +19.97% (p=0.008 n=5+5)
Encoding/v3/kube-controller-manager/JSON-36 459k ± 2% 423k ± 0% -7.97% (p=0.008 n=5+5)
Encoding/v3/kube-scheduler/JSON-36 287k ± 4% 248k ± 4% -13.59% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
Encoding/v3/kind-worker-kubelet/JSON-36 51.7MB ± 0% 58.9MB ± 0% +13.87% (p=0.029 n=4+4)
Encoding/v3/kube-apiserver/JSON-36 1.18MB ± 0% 0.55MB ± 0% -53.07% (p=0.008 n=5+5)
Encoding/v3/kube-controller-manager/JSON-36 3.33MB ± 0% 4.33MB ± 0% +30.26% (p=0.008 n=5+5)
Encoding/v3/kube-scheduler/JSON-36 923kB ± 0% 1155kB ± 0% +25.21% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
Encoding/v3/kind-worker-kubelet/JSON-36 701k ± 0% 815k ± 0% +16.25% (p=0.016 n=5+4)
Encoding/v3/kube-apiserver/JSON-36 5.12k ± 0% 6.40k ± 0% +24.97% (p=0.008 n=5+5)
Encoding/v3/kube-controller-manager/JSON-36 42.8k ± 0% 53.3k ± 0% +24.53% (p=0.008 n=5+5)
Encoding/v3/kube-scheduler/JSON-36 11.5k ± 0% 14.2k ± 0% +23.36% (p=0.029 n=4+4)
That's when the benchmark calls zapr directly ("ContextualLogging" enabled). Here's the comparison when it is off and calls go through klog:
$ benchstat zapr-master.log zapr-stream-2.log
name old msgs/s new msgs/s delta
Encoding/v3/kind-worker-kubelet/JSON-36 338k ± 0% 326k ± 1% -3.59% (p=0.008 n=5+5)
Encoding/v3/kube-apiserver/JSON-36 178k ± 3% 200k ± 1% +12.14% (p=0.008 n=5+5)
Encoding/v3/kube-controller-manager/JSON-36 343k ± 1% 322k ± 1% -6.07% (p=0.008 n=5+5)
Encoding/v3/kube-scheduler/JSON-36 195k ± 3% 177k ± 4% -9.14% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
Encoding/v3/kind-worker-kubelet/JSON-36 77.7MB ± 0% 84.9MB ± 0% +9.25% (p=0.029 n=4+4)
Encoding/v3/kube-apiserver/JSON-36 1.47MB ± 0% 0.84MB ± 0% -42.69% (p=0.008 n=5+5)
Encoding/v3/kube-controller-manager/JSON-36 5.69MB ± 0% 6.69MB ± 0% +17.69% (p=0.008 n=5+5)
Encoding/v3/kube-scheduler/JSON-36 1.53MB ± 0% 1.76MB ± 0% +15.20% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
Encoding/v3/kind-worker-kubelet/JSON-36 1.28M ± 0% 1.39M ± 0% +8.91% (p=0.029 n=4+4)
Encoding/v3/kube-apiserver/JSON-36 11.5k ± 0% 12.8k ± 0% +11.10% (p=0.029 n=4+4)
Encoding/v3/kube-controller-manager/JSON-36 95.4k ± 0% 105.9k ± 0% +11.01% (p=0.016 n=5+4)
Encoding/v3/kube-scheduler/JSON-36 25.0k ± 0% 27.6k ± 0% +10.75% (p=0.008 n=5+5)
As a side note, performance is better with contextual logging enabled.
This optimization helps with kube-apiserver, but not the other components. I suspect that creating those callbacks needs other allocations, so the benefit gets canceled out and it depends on the mix of key/value pairs which approach works better.
I'm going to let this sit for a while.
from zapr.
Related Issues (20)
- Tag a new release HOT 1
- Wrong line reported
- WithName and WithValues should preserve log level HOT 1
- "stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error HOT 3
- How to configured this to log to stdout, not stderr like bizarre Golang standard HOT 1
- Re-pin to a newer zap version
- Bump github.com/go-logr/logr v1.0.0-rc1 => v1.0.0 ?
- Incorrect number of arguments detected HOT 2
- Allow mapping between logr V() and zap log levels HOT 7
- panic messages use keys with spaces HOT 14
- DisableCaller in Zap Config HOT 1
- Why doesn't support semver spec to latest tag? HOT 4
- inconsistent logging of value vs. value embedded somewhere else HOT 2
- warn about malformed parameters HOT 1
- Logr to Zap Level Confusion HOT 3
- Data race in WithName() implementation? HOT 6
- We are unable to detect the CVE-2020-29652 vulnerability through our vulnerability scanning HOT 1
- Wrong line reported HOT 2
- Build issues on Go 1.21 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zapr.