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

perf: reduce decoder malloc & reuse existing vars #61

Merged
merged 2 commits into from
Dec 22, 2023

Conversation

muktihari
Copy link
Owner

  • decoder: use single backing array instead of creating slice on each r read since the max size is known.
  • decoder: implement reuse existing variables/instance rather than creating new one.
  • proto: remove Size in FieldBase, we can get the size from basetype.
  • profile: clean up fitgen's profile builder.go
  • generate: profile and factory

benchmark:

goos: darwin
goarch: amd64
pkg: github.com/muktihari/fit/decoder
cpu: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
                        old.txt                   new.txt                
                        sec/op         sec/op     vs base                
DecodeMessageData-4   11.317µ ± 13%   9.543µ ±  1%  -15.68% (p=0.000 n=10)
Decode-4               160.7m ± 44%   137.0m ± 11%  -14.76% (p=0.001 n=10)
geomean                1.349m         1.144m        -15.22%

                       old.txt                   new.txt               
                         B/op          B/op      vs base               
DecodeMessageData-4   3.430Ki ± 0%   3.277Ki ± 0%  -4.47% (p=0.000 n=10)
Decode-4              97.52Mi ± 0%   94.85Mi ± 0%  -2.74% (p=0.000 n=10)
geomean               585.3Ki        564.2Ki       -3.61%

                       old.txt                   new.txt               
                      allocs/op     allocs/op   vs base                
DecodeMessageData-4    136.00 ± 0%    58.00 ± 0%  -57.35% (p=0.000 n=10)
Decode-4              1900.1k ± 0%   900.1k ± 0%  -52.63% (p=0.000 n=10)
geomean                16.08k        7.225k       -55.05%

- decoder: use single backing array instead of creating slice on each r read since the max size is known.
- decoder: implement reuse existing variables/instance rather than creating new one.
- proto: remove Size in FieldBase, we can get the size from basetype.
- profile: clean up fitgen's profile builder.go
- generate: profile and factory
@muktihari muktihari added the performance Changes related to performance improvement label Dec 22, 2023
@muktihari muktihari self-assigned this Dec 22, 2023
@muktihari muktihari merged commit 5cc889c into master Dec 22, 2023
1 check passed
@muktihari muktihari deleted the perf/reduce-decoder-malloc branch December 22, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Changes related to performance improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant