Merged
Conversation
Collaborator
Author
|
Benchmarks: |
3d9e34e to
7ec20b3
Compare
stoewer
approved these changes
Nov 14, 2023
| func (s *span) Attributes() map[traceql.Attribute]traceql.Static { | ||
| return s.attributes | ||
| func (s *span) AllAttributes() map[traceql.Attribute]traceql.Static { | ||
| atts := make(map[traceql.Attribute]traceql.Static, len(s.spanAttrs)+len(s.resourceAttrs)+len(s.traceAttrs)) |
Contributor
There was a problem hiding this comment.
If I'm not mistaken AllAttributes() is currently only called once per span. I'm still wondering if it makes sense to cache atts in the span and skip the copying for consecutive calls to avoid future performance issues
Collaborator
Author
There was a problem hiding this comment.
I didn't want to cache it b/c it's possible to have attributes change between calls to AllAttributes(), but it is a very expensive call and this PR works only b/c we scan so many more spans then we turn them into the results metadata.
I added a comment here to hopefully prevent abuse of AllAttributes():
but that's not a great safeguard.
Contributor
|
Here are my benchmark results on a 5GB block from ops: |
480d775 to
a52f87d
Compare
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
a52f87d to
e446853
Compare
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.
This PR improves performance of queries that hit the engine layer by reducing allocations and map iterations. It swaps a map of all attributes in the span struct for slices at the span, resource and trace levels.
The AttributeFor function is quite important. It tests the appropriate slices if a scope is provided. Otherwise it checks the slices by attribute name only in order of precedence. This is to replicate this behavior which used to exist in the engine.
Other Changes
AttributeFor()andAllAttributes()method. Unfortunately the building of trace metadata requires getting all of the attributes and iterating through them. TheAllAttributes()method has terrible performance and should generally not be called.AttributeFor()method. This is more permissive as it first checks for direct matches and then extends its search to check the individual levels by name.Benchmarks below!