-
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
Use a variable-size array to represent ordered labels in maps #523
Conversation
Note that use of an array-valued key makes map lookups more expensive, but this is still an overall performance win. Before:
After:
|
Note that this change removes the caching of encoded labels. It's possible to regain this by adding support for the label set to cache the encoding for >=1 label encoder, instead. I did it that way in OTEP 78, see here: |
Another note: if the benchmark was to measure the cost of update-to-export of a single metric event, and we compare with previous "single encoding" optimization, this approach costs more overall because we're computing two encodings (one for the map and one for the export). I'm still happy with this direction because it reduces confusion about handling label encoders. |
We can slightly optimize this code as noted here: https://github.com/open-telemetry/opentelemetry-go/pull/523/files#diff-4c3de179542bac3c5ceacd2090215160R371 As there is a forthcoming OTEP proposing to remove LabelSet, I decided to leave several potential optimizations out. |
@bogdandrutu please 👀. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, but have some nits and questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks like an improvement for me.
…elemetry#523) * Use an array key to label encoding in the SDK * Comment * Precommit * Comment * Comment * Feedback from krnowak * Do not overwrite the Key * Add the value test requested * Add a comment
Rather than using a label encoder to encode a unique representation of the label set, we can use an
interface{}
containing an array value of the appropriate size. (This was described as "use dangerous reflection black magic" in the Metrics SIG meeting notes today.) This improve benchmarks significantly. The code has been hand-written for up to 10 labels to avoid the overhead ofreflect
.Before:
After: