-
Notifications
You must be signed in to change notification settings - Fork 833
Using sortSeries
from Select to decided to sort the response on DistributorQueryable
#4869
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
Conversation
Signed-off-by: Alan Protasio <[email protected]>
c16ac2f
to
1738431
Compare
1e9510d
to
40e51ed
Compare
Signed-off-by: Alan Protasio <[email protected]>
…ent queriables Signed-off-by: Alan Protasio <[email protected]>
Signed-off-by: Alan Protasio <[email protected]>
Signed-off-by: Alan Protasio <[email protected]>
40e51ed
to
ad61fcc
Compare
Signed-off-by: Alan Protasio <[email protected]>
bc21569
to
f960942
Compare
sets := make(chan storage.SeriesSet, len(q.queriers)) | ||
for _, querier := range q.queriers { | ||
go func(querier storage.Querier) { | ||
// We should always select sorted here as we will need to merge the series |
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.
This comment is a bit misleading because I think what you meant that is "if we need to query multiple backend, then we need to merge results which depends on the result from each querier being sorted. We are not sure if each result is sorted default, so it's safer to force sort to ensure the merge can work properly"
What this PR does:
We are always sorting the response even when its not needed.
We still need to sort the series if we are querying multiples backends (ex: ingesters + store-gateways) as the result needs to be sorted in order to be merged here.
Why we don't need to sort when querying only one backend?
Why sorting matters?
This sort can add considerable latency when fetching millions of timeseries as it have to sort all those using those tags.
Prometheus itself does similar thing on the remote_read code:
https://github.com/prometheus/prometheus/blob/d56d0a9d52c8614fdf1c5c652061929ede562f3e/storage/remote/read.go#L174
https://github.com/prometheus/prometheus/blob/d56d0a9d52c8614fdf1c5c652061929ede562f3e/storage/remote/codec.go#L148-L164
Im also removing this extra sort as it seems to not be needed as both ingesters and store-gateways should return the labels already sorted as we already make this assumption in other places like here and here
This change will also benefit GetSeries when update prometheus: See prometheus/prometheus#11311
before/after:
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]