perf(indexgateway): Only calculate chunk groups if we're going to return them - #24113
perf(indexgateway): Only calculate chunk groups if we're going to return them#24113DanHopperGrafana wants to merge 2 commits into
Conversation
Benchmark:
```
│ before.txt │ after.txt │
│ sec/op │ sec/op vs base │
BuildShardsResponse/series=10000/chunks_per_series=100-12 54.28m ± 3% 34.34m ± 1% -36.73% (p=0.000 n=10)
BuildShardsResponse/series=100000/chunks_per_series=10-12 89.12m ± 1% 69.67m ± 1% -21.82% (p=0.000 n=10)
BuildShardsResponse/series=1000000/chunks_per_series=1-12 317.1m ± 1% 292.6m ± 2% -7.73% (p=0.000 n=10)
geomean 115.3m 88.79m -23.01%
│ before.txt │ after.txt │
│ B/op │ B/op vs base │
BuildShardsResponse/series=10000/chunks_per_series=100-12 226.5Mi ± 0% 157.3Mi ± 0% -30.58% (p=0.000 n=10)
BuildShardsResponse/series=100000/chunks_per_series=10-12 266.4Mi ± 0% 197.1Mi ± 0% -26.00% (p=0.000 n=10)
BuildShardsResponse/series=1000000/chunks_per_series=1-12 400.6Mi ± 0% 331.3Mi ± 0% -17.30% (p=0.000 n=10)
geomean 289.2Mi 217.4Mi -24.82%
│ before.txt │ after.txt │
│ allocs/op │ allocs/op vs base │
BuildShardsResponse/series=10000/chunks_per_series=100-12 1087.75k ± 0% 85.22k ± 0% -92.17% (p=0.000 n=10)
BuildShardsResponse/series=100000/chunks_per_series=10-12 1508.5k ± 0% 506.0k ± 0% -66.45% (p=0.000 n=10)
BuildShardsResponse/series=1000000/chunks_per_series=1-12 2.024M ± 0% 1.021M ± 0% -49.53% (p=0.000 n=10)
geomean 1.492M 353.2k -76.33%
```
joe-elliott
left a comment
There was a problem hiding this comment.
some Qs and thoughts, but i'm good on the merge. nice improvement!
give me a ping if you make changes and want a second review
| seen[model.Fingerprint(ref.Fingerprint)] = struct{}{} | ||
| } | ||
| resp.Statistics.Index.TotalStreams = int64(len(seen)) | ||
| seen := make(map[model.Fingerprint]struct{}, 1024) |
There was a problem hiding this comment.
thoughts on the impact of perfectly counting streams? is this useful? costly?
is there a proxy value or approx count that would work just as well?
| @@ -2,8 +2,10 @@ package indexgateway | |||
|
|
|||
| import ( | |||
| "context" | |||
There was a problem hiding this comment.
now that you have broken them out there is an opportunity to test chunkGroupsForShards and buildShardsResponse directly
| for _, s := range shards { | ||
| from := sort.Search(len(filtered), func(i int) bool { | ||
| return filtered[i].Fingerprint >= uint64(s.Bounds.Min) | ||
| from := sort.Search(len(chunkRefs), func(i int) bool { |
There was a problem hiding this comment.
this is outside the point of this PR, but does this actually work? are chunkRefs guaranteed to be sorted?
they come from the call GetChunkRefsWithSizingInfo and they do not appear to be sorted in at least this implementation
What this PR does / why we need it:
Two commits:
Benchmark results:
Which issue(s) this PR fixes: N/A
Special notes for your reviewer: I recommend reviewing the commits separately.
Checklist
CONTRIBUTING.mdguide (required)docs/sources/setup/upgrade/_index.mddeprecated-config.yamlanddeleted-config.yamlfiles respectively in thetools/deprecated-config-checkerdirectory. Example PR