Simplify the last-value aggregate#4343
Merged
Merged
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4343 +/- ##
=====================================
Coverage 83.4% 83.4%
=====================================
Files 184 184
Lines 14349 14360 +11
=====================================
+ Hits 11975 11988 +13
+ Misses 2147 2145 -2
Partials 227 227
|
Instead of treating the returned *lastValue as an aggregator from newLastValue, just use the type directly to construct the Measure and ComputeAggregation functions returned from the Builder. Accept a destination type for the underlying computeAggregation. This allows memory reuse for collections which adds a considerable optimization. Simplify the integration testing of the last-value aggregate. Update benchmarking.
pellared
reviewed
Jul 20, 2023
dashpole
approved these changes
Jul 20, 2023
Co-authored-by: Robert Pająk <pellared@hotmail.com>
pellared
approved these changes
Jul 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #4220
Instead of treating the returned *lastValue as an aggregator from newLastValue, just use the type directly to construct the Measure and ComputeAggregation functions returned from the Builder.
Accept a destination type for the underlying computeAggregation. This allows memory reuse for collections which adds a considerable optimization.
Simplify the integration testing of the last-value aggregate.
Update benchmarking.
Benchmarking
Measure
goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/metric/internal/aggregate cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ LastValue/Int64/1/Measure-8 137.6n ± 1% 148.3n ± 4% +7.82% (p=0.000 n=10) LastValue/Int64/10/Measure-8 1.689µ ± 4% 1.686µ ± 3% ~ (p=0.631 n=10) LastValue/Int64/100/Measure-8 16.41µ ± 5% 17.31µ ± 2% +5.47% (p=0.002 n=10) LastValue/Float64/1/Measure-8 150.4n ± 4% 150.8n ± 5% ~ (p=0.853 n=10) LastValue/Float64/10/Measure-8 1.731µ ± 6% 1.770µ ± 3% ~ (p=0.383 n=10) LastValue/Float64/100/Measure-8 16.87µ ± 6% 16.89µ ± 5% ~ (p=1.000 n=10) geomean 1.599µ 1.641µ +2.59% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ LastValue/Int64/1/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Int64/10/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Int64/100/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/1/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/10/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/100/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ geomean ² +0.00% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ LastValue/Int64/1/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Int64/10/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Int64/100/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/1/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/10/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ LastValue/Float64/100/Measure-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ geomean ² +0.00% ² ¹ all samples are equal ² summaries must be >0 to compute geomeanComputeAggregation
goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/metric/internal/aggregate cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ LastValue/Int64/1/ComputeAggregation-8 387.0n ± 10% 269.0n ± 5% -30.49% (p=0.000 n=10) LastValue/Int64/10/ComputeAggregation-8 2.278µ ± 3% 1.657µ ± 6% -27.28% (p=0.000 n=10) LastValue/Int64/100/ComputeAggregation-8 19.79µ ± 3% 15.38µ ± 2% -22.27% (p=0.000 n=10) LastValue/Float64/1/ComputeAggregation-8 413.6n ± 10% 283.5n ± 6% -31.46% (p=0.000 n=10) LastValue/Float64/10/ComputeAggregation-8 2.325µ ± 7% 1.661µ ± 6% -28.56% (p=0.000 n=10) LastValue/Float64/100/ComputeAggregation-8 20.12µ ± 5% 15.39µ ± 5% -23.53% (p=0.000 n=10) geomean 2.639µ 1.917µ -27.34% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ LastValue/Int64/1/ComputeAggregation-8 120.00 ± 0% 24.00 ± 0% -80.00% (p=0.000 n=10) LastValue/Int64/10/ComputeAggregation-8 1048.00 ± 0% 24.00 ± 0% -97.71% (p=0.000 n=10) LastValue/Int64/100/ComputeAggregation-8 9752.00 ± 0% 24.00 ± 0% -99.75% (p=0.000 n=10) LastValue/Float64/1/ComputeAggregation-8 120.00 ± 0% 24.00 ± 0% -80.00% (p=0.000 n=10) LastValue/Float64/10/ComputeAggregation-8 1048.00 ± 0% 24.00 ± 0% -97.71% (p=0.000 n=10) LastValue/Float64/100/ComputeAggregation-8 9752.00 ± 0% 24.00 ± 0% -99.75% (p=0.000 n=10) geomean 1.045Ki 24.00 -97.76% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ LastValue/Int64/1/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) LastValue/Int64/10/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) LastValue/Int64/100/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) LastValue/Float64/1/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) LastValue/Float64/10/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) LastValue/Float64/100/ComputeAggregation-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) geomean 2.000 1.000 -50.00%