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

Upstream patched binary package from cilium #4

Closed
lmb opened this issue Sep 6, 2019 · 3 comments
Closed

Upstream patched binary package from cilium #4

lmb opened this issue Sep 6, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@lmb
Copy link
Collaborator

lmb commented Sep 6, 2019

Currently, marshaling a 24 byte via binary allocates quite a lot:

name                      time/op
Marshalling/reflection-8  1.27µs ± 8%
Marshalling/custom-8       730ns ± 6%
Marshalling/unsafe-8       662ns ± 5%

name                      alloc/op
Marshalling/reflection-8    152B ± 0%
Marshalling/custom-8       32.0B ± 0%
Marshalling/unsafe-8       0.00B

name                      allocs/op
Marshalling/reflection-8    8.00 ± 0%
Marshalling/custom-8        1.00 ± 0%
Marshalling/unsafe-8        0.00

Cilium proper has a patched binary package which reduces allocations: https://github.com/cilium/cilium/tree/master/pkg/bpf/binary

@lmb
Copy link
Collaborator Author

lmb commented Nov 4, 2019

I managed to improve the performance of binary.Read and Write for structs. Improvement of go tip over 1.13:

name                    old time/op    new time/op    delta
Marshalling/reflection    1.24µs ± 1%    1.00µs ± 1%  -19.38%  (p=0.008 n=5+5)

name                    old alloc/op   new alloc/op   delta
Marshalling/reflection      152B ± 0%      112B ± 0%  -26.32%  (p=0.008 n=5+5)

name                    old allocs/op  new allocs/op  delta
Marshalling/reflection      8.00 ± 0%      3.00 ± 0%  -62.50%  (p=0.008 n=5+5)

See golang/go#34471

@lmb lmb added the enhancement New feature or request label Nov 6, 2019
@tklauser
Copy link
Member

Is there anything else to do here? It seems @lmb's performance improvement made it upstream (golang/go@c9d89f6) and will be part of Go 1.14.

@lmb
Copy link
Collaborator Author

lmb commented Feb 25, 2020

I'm happy to close this as a wontfix. If cilium needs more perf you can implement BinaryMarshaler, or use unsafe.Pointer for every last drop.

@lmb lmb added the wontfix label Mar 3, 2020
@lmb lmb closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants