Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btf: Optimizing BTF parsing by merging
readTypes
and inflateRawTypes
After profiling the BTF parsing code, it became apparent that a lot of time was spent in `readTypes` was spent allocating rawTypes. These rawTypes are only used as an intermediate step to create the final inflated types so all of the allocation work gets thrown away. This commit merges `readTypes` and `inflateRawTypes` into a single function. This allows us to re-use the intermediate objects and only allocate the final inflated types. This results in the following performance improvements: ``` 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 49.05m ± 1% 46.08m ± 1% -6.06% (n=100) │ before.txt │ after.txt │ │ B/op │ B/op vs base │ ParseVmlinux-16 31.45Mi ± 0% 26.65Mi ± 0% -15.28% (n=100) │ before.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ ParseVmlinux-16 534.1k ± 0% 467.5k ± 0% -12.48% (n=100) ``` Signed-off-by: Dylan Reimerink <[email protected]>
- Loading branch information