feat: reduce allocs in query sharder#3932
Conversation
joe-elliott
left a comment
There was a problem hiding this comment.
Looks like there's some minor conflicts to resolve. Once that's done we'll merge.
| reqs[i] = parent.Clone(ctx) | ||
|
|
||
| q := reqs[i].URL.Query() | ||
| qb := api.NewQueryBuilder(reqs[i].URL.RawQuery) |
There was a problem hiding this comment.
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.
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.
I think it's better to pass a map. The map can be reused to reduce allocations.
There was a problem hiding this comment.
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.
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.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]