Following @pracucci idea from last Thanos Community Sync in order to reduce and predict better memory usage of Thanos Store Gateway per query.
The idea is to move Block index lookup to a separate, first stage and do it concurrently for all blocks that potentially can match the query. We pack all in some kind of merge sort series set.
Then we can have a defined number of workers that get series IDs and fetches chunks for them send to stream (in the right order).
This way we can highly control the overall resources per requests used. This is even more important because we overfetch chunk bytes from object storage to avoid API rate limits. Holding those bytes as short as possible and only for few series / blocks, make a lot of sense. (:
Help wanted, whoever have time first. It's big refactor.
Some comments we made on code while 1:1 to @yeya24
https://github.com/thanos-io/thanos/compare/comments?expand=1
@bwplotka @yeya24 I think we're missing the content of the comments? Could you please check the link again?
Just click the link and scroll down you see comments in the code added
@yeya24 is on it :hugs:
Most helpful comment
@yeya24 is on it :hugs: