-
Notifications
You must be signed in to change notification settings - Fork 521
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
feat: reduce allocs in query sharder #3932
feat: reduce allocs in query sharder #3932
Conversation
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.
Looks like there's some minor conflicts to resolve. Once that's done we'll merge.
modules/frontend/traceid_sharder.go
Outdated
@@ -75,17 +76,18 @@ func (s *asyncTraceSharder) buildShardedRequests(ctx context.Context, parent *ht | |||
for i := 0; i < len(s.blockBoundaries); i++ { | |||
reqs[i] = parent.Clone(ctx) | |||
|
|||
q := reqs[i].URL.Query() | |||
qb := api.NewQueryBuilder(reqs[i].URL.RawQuery) |
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.
wdyt about making an api.Build...()
method and leaving the query builder unexported from the pkg/api
pacakge?
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.
Something like this?
// It returns an URL with query params
func BuildQuery(url string, args ...string) (string, error) {
}
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.
I think it's better to pass a map. The map can be reused to reduce allocations.
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.
I was actually thinking of something like this:
https://github.com/grafana/tempo/blob/main/pkg/api/http.go#L462
That takes this proto struct and encodes it into an http request:
https://github.com/grafana/tempo/blob/main/pkg/tempopb/tempo.proto#L50C9-L50C25
and turns it into an http request. Mainly for consistency with the other http requests. Not a blocker just something to consider.
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.
Gotcha, I've done the same but with the map and as a generic helper. I think it's nice to have it. I've moved the method to the commonplace and used the same structure
What this PR does:
Reduce memory allocations when sharding the query. Similar perf improvement as #3901
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]