-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Pool sortables used to create attribute sets #3832
Merged
Merged
Conversation
This file contains 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
MrAlias
added
pkg:SDK
Related to an SDK package
area:metrics
Part of OpenTelemetry Metrics
labels
Mar 3, 2023
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3832 +/- ##
=====================================
Coverage 81.8% 81.8%
=====================================
Files 169 169
Lines 12570 12581 +11
=====================================
+ Hits 10283 10294 +11
Misses 2072 2072
Partials 215 215
|
MrAlias
requested review from
jmacd,
Aneurysm9,
evantorrie,
XSAM,
dashpole,
MadVikingGod,
pellared,
hanyuancheung and
dmathieu
as code owners
March 3, 2023 19:22
MrAlias
changed the title
Pool sortables used to create attribute sets in metric SDK
Pool sortables used to create attribute sets
Mar 3, 2023
Petrie
suggested changes
Mar 6, 2023
Co-authored-by: Peter Liu <lpfvip2008@gmail.com>
pellared
approved these changes
Mar 8, 2023
Co-authored-by: Robert Pająk <pellared@hotmail.com>
MadVikingGod
approved these changes
Mar 10, 2023
pellared
approved these changes
Mar 13, 2023
Merged
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.
The metric SDK converts accepted attribute slices into attribute
Set
s. Currently it creates a temporary slice to sort the attributes each time a measurement is made and it does so for each aggregation. This change optimizes thatSet
creation in the following ways:Set
for each aggregation. Attribute sets are immutable and the only operation the aggregation will perform on them is to filter. Filtering is an operation that returns a new copiedSet
. Therefore, reusing the attribute set across all aggregations means allocations only need to be made once.Sortable
in theattribute
package to createSet
s that the user does not provide their ownSortable
. This amortizes the cost of allocating a new temporary sorting slice during theSet
creation across allSet
creations.Benchmarks
This amortizes the allocation of a
Sortable
across multiple instrument measurements, meaning the benchmarks show one less allocation per measurement per aggregation.