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 stringTable to speed up vmlinux parsing #1203

Merged
merged 2 commits into from
Nov 7, 2023

Commits on Nov 3, 2023

  1. btf: remove unused stringTable.Marshal

    The library now uses stringTableBuilder instead.
    
    Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
    lmb committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    3d3d72e View commit details
    Browse the repository at this point in the history
  2. btf: add fast path for string table offset 0 lookup

    It turns out that the vast majority of string table lookups are for
    offset zero, which is always defined to be the empty string.
    
    This gives a good 14% speedup on my machine:
    
        goos: linux
        goarch: amd64
        pkg: github.com/cilium/ebpf/btf
        cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                        │  base.txt   │              zero.txt              │
                        │   sec/op    │   sec/op     vs base               │
        ParseVmlinux-16   50.14m ± 7%   43.07m ± 3%  -14.10% (p=0.002 n=6)
    
                        │   base.txt   │           zero.txt            │
                        │     B/op     │     B/op      vs base         │
        ParseVmlinux-16   31.45Mi ± 0%   31.45Mi ± 0%  ~ (p=0.485 n=6)
    
                        │  base.txt   │           zero.txt           │
                        │  allocs/op  │  allocs/op   vs base         │
        ParseVmlinux-16   534.1k ± 0%   534.1k ± 0%  ~ (p=0.461 n=6)
    
    Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
    lmb committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    c934406 View commit details
    Browse the repository at this point in the history