Skip to content
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

btf: optimize Spec.Copy #1002

Merged
merged 3 commits into from
Apr 19, 2023
Merged

btf: optimize Spec.Copy #1002

merged 3 commits into from
Apr 19, 2023

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Apr 6, 2023

btf: avoid allocating typeDeque in copier.copy

    goos: linux
    goarch: amd64
    pkg: github.com/cilium/ebpf/btf
    cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                │   old.txt   │              new.txt               │
                │   sec/op    │   sec/op     vs base               │
    SpecCopy-16   37.76m ± 2%   33.27m ± 5%  -11.91% (p=0.002 n=6)

                │   old.txt    │               new.txt               │
                │     B/op     │     B/op      vs base               │
    SpecCopy-16   38.10Mi ± 0%   32.28Mi ± 0%  -15.27% (p=0.002 n=6)

                │   old.txt   │              new.txt               │
                │  allocs/op  │  allocs/op   vs base               │
    SpecCopy-16   294.7k ± 0%   203.2k ± 0%  -31.05% (p=0.002 n=6)

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

btf: pre-size copier

Make sure copier has the appropriate size from the start.

    goos: linux
    goarch: amd64
    pkg: github.com/cilium/ebpf/btf
    cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                │   old.txt   │              new.txt               │
                │   sec/op    │   sec/op     vs base               │
    SpecCopy-16   43.96m ± 8%   37.76m ± 2%  -14.10% (p=0.002 n=6)

                │   old.txt    │               new.txt               │
                │     B/op     │     B/op      vs base               │
    SpecCopy-16   48.44Mi ± 0%   38.10Mi ± 0%  -21.36% (p=0.002 n=6)

                │   old.txt   │              new.txt              │
                │  allocs/op  │  allocs/op   vs base              │
    SpecCopy-16   299.3k ± 0%   294.7k ± 0%  -1.56% (p=0.002 n=6)

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

btf: add Spec.Copy benchmark

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

lmb added 3 commits April 6, 2023 11:49
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Make sure copier has the appropriate size from the start.

    goos: linux
    goarch: amd64
    pkg: github.com/cilium/ebpf/btf
    cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                │   old.txt   │              new.txt               │
                │   sec/op    │   sec/op     vs base               │
    SpecCopy-16   43.96m ± 8%   37.76m ± 2%  -14.10% (p=0.002 n=6)

                │   old.txt    │               new.txt               │
                │     B/op     │     B/op      vs base               │
    SpecCopy-16   48.44Mi ± 0%   38.10Mi ± 0%  -21.36% (p=0.002 n=6)

                │   old.txt   │              new.txt              │
                │  allocs/op  │  allocs/op   vs base              │
    SpecCopy-16   299.3k ± 0%   294.7k ± 0%  -1.56% (p=0.002 n=6)

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
    goos: linux
    goarch: amd64
    pkg: github.com/cilium/ebpf/btf
    cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                │   old.txt   │              new.txt               │
                │   sec/op    │   sec/op     vs base               │
    SpecCopy-16   37.76m ± 2%   33.27m ± 5%  -11.91% (p=0.002 n=6)

                │   old.txt    │               new.txt               │
                │     B/op     │     B/op      vs base               │
    SpecCopy-16   38.10Mi ± 0%   32.28Mi ± 0%  -15.27% (p=0.002 n=6)

                │   old.txt   │              new.txt               │
                │  allocs/op  │  allocs/op   vs base               │
    SpecCopy-16   294.7k ± 0%   203.2k ± 0%  -31.05% (p=0.002 n=6)

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb requested a review from rgo3 April 6, 2023 13:03
@lmb lmb requested a review from ti-mo April 19, 2023 12:54
Copy link
Contributor

@rgo3 rgo3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newbie question: how did you create those outputs that you put into the commit messages?

@lmb
Copy link
Collaborator Author

lmb commented Apr 19, 2023

@lmb lmb merged commit 5b305b2 into cilium:master Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants