-
Notifications
You must be signed in to change notification settings - Fork 651
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: support marshaling Type #641
Closed
Closed
Conversation
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
As always, needs some more work! |
Replace intEncoding with a type. This allows adding setters.
The kernel refuses to load an array type without an index type, so probably btf.rst is outdated.
Split typeDeque into a separate file to reduce the amount of code in types.go.
A stringTableBuilder helps build a BTF-style string table, which delimits individual strings with a 0 byte. Each unique string is only added to the table once.
Type.walk takes a *typeDeque as argument. Go escape analysis doesn't see through interface boundaries and therefore always allocates such pointers on the heap. This forces typeDeque to always be heap allocated, which makes traversal more expensive than it has to be. Replace the interface function with walkType, which essentially contains a big type switch.
Allow building BTF wire format from scratch. We can compare a full vmlinux build to just re-encoding raw type data as we currently do in Spec.marshal: name time/op BuildVmlinux/builder-4 77.9ms ± 2% BuildVmlinux/native-4 23.3ms ± 2% name alloc/op BuildVmlinux/builder-4 33.7MB ± 0% BuildVmlinux/native-4 20.1MB ± 0% name allocs/op BuildVmlinux/builder-4 473k ± 0% BuildVmlinux/native-4 394k ± 0% A full rebuild is about 3x slower and uses 1.6x the memory. We can't use the builder to replace Spec.marshal yet, since we don't have a good way to include LineInfos in the generated BTF. This will become easier once LineInfos are stored in Instruction metadata. Updates cilium#616
This works now! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first cut at adding a
btf.Builder
which allows turningType
into BTF that the kernel understands. The code can round-trip vmlinux BTF and then load the result into the kernel, which is a good indication that we covered most of the bases.As it stands, the builder is not exported or used in the package, since there is currently no way to add strings necessary for
LineInfo
to the BTF. This should become a lot easier once #606 lands.Best reviewed per commit.
btf: add btfInt
btf: add Array.Index
btf: move typeDeque to separate file
btf: add stringTableBuilder
btf: replace Type.walk with walkType
btf: add builder