Skip to content
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

Cache expanded postings #6417

Closed
yeya24 opened this issue Jun 6, 2023 · 2 comments · Fixed by #6420
Closed

Cache expanded postings #6417

yeya24 opened this issue Jun 6, 2023 · 2 comments · Fixed by #6420

Comments

@yeya24
Copy link
Contributor

yeya24 commented Jun 6, 2023

Is your proposal related to a problem?

#6416 mentioned some problems when fetching postings. One thing is that, if the postings contain a lot of series IDs but after intersection it only matches few series, we still need to fetch postings for all matchers

Describe the solution you'd like

We can try to cache the postings after expansion. This could save both CPU time for merging postings and mem/bandwidth for fetching postings from caches.

Let's say a query up{cluster="us", env="prod"}. Each matcher matches 100, 100K and 500K respectively and we need to fetch 600K postings.
If we have expanded postings cached, we only need to fetch < 100 postings.

Describe alternatives you've considered

Add new methods in index cache to store and fetch expanded postings. The data format can reuse what we have: store diff+varint+streamed snappy and the cache key will be blockID + label matchers.

@fpetkovski
Copy link
Contributor

I wonder if postings would be better suited on disk with the index header, instead of in object storage 🤔

@yeya24
Copy link
Contributor Author

yeya24 commented Jun 6, 2023

@fpetkovski I think it is a good point. Maybe we could experiment with that. From some real data I can see, the posting part is relatively small compared to the series section in tsdb index so probably we can try that.

But I still think it is valuable to cache expanded postings as we don't have to process label matchers and do intersections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants