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

Add sync.Pool to reduce allocations for the default case in unmarshalBytes() #420

Merged
merged 1 commit into from
Sep 16, 2021
Merged

Add sync.Pool to reduce allocations for the default case in unmarshalBytes() #420

merged 1 commit into from
Sep 16, 2021

Conversation

rockdaboot
Copy link
Contributor

This change avoids the allocations for bytes.Reader.

…marshalBytes()

This change avoids the allocations for bytes.Reader.
@lmb
Copy link
Collaborator

lmb commented Sep 16, 2021

I think this is a net positive:

name                      old time/op    new time/op    delta
Marshalling/reflection-8    1.02µs ± 1%    1.00µs ± 1%   -1.90%  (p=0.029 n=4+4)
Marshalling/custom-8         756ns ± 0%     757ns ± 1%     ~     (p=0.486 n=4+4)
Marshalling/unsafe-8         712ns ± 2%     711ns ± 1%     ~     (p=1.000 n=4+4)

name                      old alloc/op   new alloc/op   delta
Marshalling/reflection-8     96.0B ± 0%     48.0B ± 0%  -50.00%  (p=0.029 n=4+4)
Marshalling/custom-8         24.0B ± 0%     24.0B ± 0%     ~     (all equal)
Marshalling/unsafe-8         0.00B          0.00B          ~     (all equal)

name                      old allocs/op  new allocs/op  delta
Marshalling/reflection-8      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.029 n=4+4)
Marshalling/custom-8          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Marshalling/unsafe-8          0.00           0.00          ~     (all equal)

@lmb lmb merged commit 723f571 into cilium:master Sep 16, 2021
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