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: fix up inflated types immediately if possible #638

Merged
merged 1 commit into from
Apr 24, 2022

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Apr 23, 2022

Converting []rawType into []Type currently creates a lot of temporary
data in the form of fixups. They are necessary since a type may reference
itself, for example in a linked list:

struct node {
    struct node* next;
    ...
}

No matter which order we encode struct node and struct node* in, we
can't resolve one of the types until we've inflated both.

However, such self referential types are rare. Most of the time we
are referencing an already inflated type. We can use this to our
advantage and perform fixups opportunistically. At the same time
we can split out type assertions from fixups, since most fixups
don't care about types at all.

name            old time/op    new time/op    delta
ParseVmlinux-4    68.9ms ± 2%    58.4ms ± 1%  -15.22%  (p=0.029 n=4+4)

name            old alloc/op   new alloc/op   delta
ParseVmlinux-4    48.4MB ± 0%    45.2MB ± 0%   -6.69%  (p=0.029 n=4+4)

name            old allocs/op  new allocs/op  delta
ParseVmlinux-4      721k ± 0%      721k ± 0%     ~     (p=0.057 n=4+4)

Updates #542

@lmb lmb requested a review from paulcacheux April 23, 2022 14:00

Verified

This commit was signed with the committer’s verified signature.
ti-mo Timo Beckers
Converting []rawType into []Type currently creates a lot of temporary
data in the form of fixups. They are necessary since a type may reference
itself, for example in a linked list:

    struct node {
        struct node* next;
        ...
    }

No matter which order we encode struct node and struct node* in, we
can't resolve one of the types until we've inflated both.

However, such self referential types are rare. Most of the time we
are referencing an already inflated type. We can use this to our
advantage and perform fixups opportunistically. At the same time
we can split out type assertions from fixups, since most fixups
don't care about types at all.

    name            old time/op    new time/op    delta
    ParseVmlinux-4    68.9ms ± 2%    58.4ms ± 1%  -15.22%  (p=0.029 n=4+4)

    name            old alloc/op   new alloc/op   delta
    ParseVmlinux-4    48.4MB ± 0%    45.2MB ± 0%   -6.69%  (p=0.029 n=4+4)

    name            old allocs/op  new allocs/op  delta
    ParseVmlinux-4      721k ± 0%      721k ± 0%     ~     (p=0.057 n=4+4)

Updates cilium#542
@lmb lmb force-pushed the btf-reduce-fixups branch from 30c28b4 to 166c2db Compare April 23, 2022 14:00
@lmb
Copy link
Collaborator Author

lmb commented Apr 23, 2022

@paulcacheux looking at your commit I realised that there is even more improvements to be had. Please take a look.

@lmb lmb merged commit 6da9518 into cilium:master Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants