GithubHelp home page GithubHelp logo

Comments (1)

pohly avatar pohly commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.