Skip to content

Commit

Permalink
btf: remove useless pointer from newLineInfo
Browse files Browse the repository at this point in the history
    goos: linux
    goarch: amd64
    pkg: github.com/cilium/ebpf
    cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                            │  base.txt   │              new.txt               │
                            │   sec/op    │   sec/op     vs base               │
    LoadCollectionManyProgs   1.166m ± 2%   1.145m ± 1%  -1.84% (p=0.000 n=10)

                            │   base.txt   │               new.txt               │
                            │     B/op     │     B/op      vs base               │
    LoadCollectionManyProgs   699.0Ki ± 0%   693.3Ki ± 0%  -0.81% (p=0.000 n=10)

                            │  base.txt   │              new.txt               │
                            │  allocs/op  │  allocs/op   vs base               │
    LoadCollectionManyProgs   6.452k ± 0%   6.092k ± 0%  -5.58% (p=0.000 n=10)

Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
  • Loading branch information
paulcacheux authored and lmb committed Nov 8, 2023
1 parent da1ce64 commit 1027911
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions btf/ext_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,21 +556,21 @@ func LoadLineInfos(reader io.Reader, bo binary.ByteOrder, recordNum uint32, spec
return newLineInfos(lis, spec.strings)
}

func newLineInfo(li bpfLineInfo, strings *stringTable) (*lineInfo, error) {
func newLineInfo(li bpfLineInfo, strings *stringTable) (lineInfo, error) {
line, err := strings.Lookup(li.LineOff)
if err != nil {
return nil, fmt.Errorf("lookup of line: %w", err)
return lineInfo{}, fmt.Errorf("lookup of line: %w", err)
}

fileName, err := strings.Lookup(li.FileNameOff)
if err != nil {
return nil, fmt.Errorf("lookup of filename: %w", err)
return lineInfo{}, fmt.Errorf("lookup of filename: %w", err)
}

lineNumber := li.LineCol >> bpfLineShift
lineColumn := li.LineCol & bpfColumnMax

return &lineInfo{
return lineInfo{
&Line{
fileName,
line,
Expand All @@ -590,7 +590,7 @@ func newLineInfos(blis []bpfLineInfo, strings *stringTable) (LineInfos, error) {
if err != nil {
return LineInfos{}, fmt.Errorf("offset %d: %w", bli.InsnOff, err)
}
lis.infos = append(lis.infos, *li)
lis.infos = append(lis.infos, li)
}
sort.Slice(lis.infos, func(i, j int) bool {
return lis.infos[i].offset <= lis.infos[j].offset
Expand Down

0 comments on commit 1027911

Please sign in to comment.