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

Reduce allocs #116

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Reduce allocs #116

wants to merge 9 commits into from

Conversation

kbatyr
Copy link

@kbatyr kbatyr commented Oct 31, 2022

Refactor goflow package to escape allocations while parsing NetFlow/IPFIX packets.
Benchmark results before refactoring:

goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
BenchmarkNetFlow2-8   	   54494	     22757 ns/op	   15512 B/op	     400 allocs/op

And after refactoring:

goos: linux
goarch: amd64
pkg: github.com/cloudflare/goflow/v3/parsers
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
BenchmarkNetFlow1-8              2067685               529.6 ns/op           194 B/op          6 allocs/op
BenchmarkNetFlow2-8               313855              3765 ns/op             128 B/op          4 allocs/op
BenchmarkNetFlow3-8               377473              3141 ns/op               0 B/op          0 allocs/op
BenchmarkNetFlowIPFix1-8         1987146               571.7 ns/op            32 B/op          1 allocs/op
BenchmarkNetFlowIPFix2-8         3976148               277.8 ns/op            64 B/op          1 allocs/op
BenchmarkNetFlowIPFix3-8         3392520               306.3 ns/op             0 B/op          0 allocs/op
PASS
ok      github.com/cloudflare/goflow/v3/parsers 10.248s

P.S. Cases with allocations occurs when we get new template or in error cases (template not found, etc.) by calling NewError().

Batyrkhan Koshenov added 6 commits November 1, 2022 21:28
…d allocs; refactor String() method

Signed-off-by: Batyrkhan Koshenov <[email protected]>
…hub.com/klauspost/compress

Signed-off-by: Batyrkhan Koshenov <[email protected]>
Batyrkhan Koshenov added 3 commits December 2, 2022 15:15
Signed-off-by: Batyrkhan Koshenov <[email protected]>
Signed-off-by: Batyrkhan Koshenov <[email protected]>
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.

2 participants