-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btf: Replace
binary.Read
with manual parsing in readAndInflateTypes
During profiling `binary.Read` uses up a significant amount of CPU time. This seems to be due to it using reflection to calculate the amount of bytes to read at runtime and not caching these results. By doing manual `io.ReadFull` calls, pre-calculating struct sizes and reusing types and buffers where possible, we can reduce the CPU time spent in `readAndInflateTypes` by almost 25%. ``` goos: linux goarch: amd64 pkg: github.com/cilium/ebpf/btf cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz │ before.txt │ after.txt │ │ sec/op │ sec/op vs base │ ParseVmlinux-16 46.08m ± 1% 34.59m ± 2% -24.93% (n=100) │ before.txt │ after.txt │ │ B/op │ B/op vs base │ ParseVmlinux-16 26.65Mi ± 0% 23.49Mi ± 0% -11.87% (n=100) │ before.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ ParseVmlinux-16 467.5k ± 0% 267.7k ± 0% -42.73% (n=100) ``` Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
- Loading branch information
1 parent
b66beaa
commit 97891cc
Showing
2 changed files
with
234 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.