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

Avoid alloc on creating hashable func #33

Merged
merged 3 commits into from
Jul 24, 2023

Conversation

carsonip
Copy link
Member

benchstat:

goos: linux
goarch: amd64
pkg: github.com/elastic/apm-aggregation/aggregators
cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
                            │ bench-out/hashable-func-alloc-before │ bench-out/hashable-func-alloc-after │
                            │                sec/op                │   sec/op     vs base                │
AggregateCombinedMetrics-16                            4.003µ ± 3%   4.072µ ± 2%        ~ (p=0.342 n=10)
AggregateBatchSerial-16                                10.46µ ± 3%   10.26µ ± 4%        ~ (p=0.645 n=10)
AggregateBatchParallel-16                              11.07µ ± 5%   10.73µ ± 5%        ~ (p=0.190 n=10)
CombinedMetricsEncoding-16                             4.842µ ± 2%   4.829µ ± 3%        ~ (p=0.869 n=10)
CombinedMetricsDecoding-16                             4.449µ ± 2%   4.494µ ± 2%        ~ (p=0.247 n=10)
CombinedMetricsToBatch-16                              417.2µ ± 3%   418.9µ ± 2%        ~ (p=0.912 n=10)
EventToCombinedMetrics-16                             1007.0n ± 2%   845.4n ± 2%  -16.05% (p=0.000 n=10)
geomean                                                8.832µ        8.588µ        -2.77%

                            │ bench-out/hashable-func-alloc-before │  bench-out/hashable-func-alloc-after   │
                            │                 B/op                 │     B/op      vs base                  │
AggregateCombinedMetrics-16                         4.862Ki ± 2%     4.868Ki ± 1%        ~ (p=0.956 n=10)
AggregateBatchSerial-16                             11.48Ki ± 1%     11.34Ki ± 0%   -1.17% (p=0.000 n=10)
AggregateBatchParallel-16                           11.51Ki ± 1%     11.32Ki ± 1%   -1.67% (p=0.000 n=10)
CombinedMetricsEncoding-16                            0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
CombinedMetricsDecoding-16                          10.01Ki ± 0%     10.01Ki ± 0%        ~ (p=0.593 n=10)
CombinedMetricsToBatch-16                           37.66Ki ± 0%     37.66Ki ± 0%        ~ (p=1.000 n=10) ¹
EventToCombinedMetrics-16                             80.00 ± 0%       16.00 ± 0%  -80.00% (p=0.000 n=10)
geomean                                                          ²                 -20.85%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                            │ bench-out/hashable-func-alloc-before │ bench-out/hashable-func-alloc-after  │
                            │              allocs/op               │ allocs/op   vs base                  │
AggregateCombinedMetrics-16                           39.00 ± 3%     39.00 ± 3%        ~ (p=1.000 n=10)
AggregateBatchSerial-16                               79.00 ± 0%     67.00 ± 1%  -15.19% (p=0.000 n=10)
AggregateBatchParallel-16                             79.00 ± 0%     67.00 ± 0%  -15.19% (p=0.000 n=10)
CombinedMetricsEncoding-16                            0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
CombinedMetricsDecoding-16                            40.00 ± 0%     40.00 ± 0%        ~ (p=1.000 n=10) ¹
CombinedMetricsToBatch-16                             308.0 ± 0%     308.0 ± 0%        ~ (p=1.000 n=10) ¹
EventToCombinedMetrics-16                             6.000 ± 0%     2.000 ± 0%  -66.67% (p=0.000 n=10)
geomean                                                          ²               -18.46%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

@carsonip carsonip requested a review from a team as a code owner July 20, 2023 18:03
Copy link
Contributor

@lahsivjar lahsivjar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🎉 ! I was thinking of writing a protoc generator to generate these hash functions, my brain didn't even think that we can just add the hash functions in the generated proto directory 🤦

@@ -327,7 +328,7 @@ func (k *TransactionAggregationKey) FromProto(pb *aggregationpb.TransactionAggre
k.TransactionType = pb.TransactionType
k.TransactionResult = pb.TransactionResult

k.FAASColdstart = NullableBool(pb.FaasColdstart)
k.FAASColdstart = nullable.NullableBool(pb.FaasColdstart)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can change nullable.NullableBool to nullable.Bool

@carsonip carsonip merged commit a8a264d into elastic:main Jul 24, 2023
2 checks passed
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