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

optimize store gateway bytes limiter reserve with type request #8025

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Dec 29, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

bytesLimiter.ReserveWithType is an interface that can be customized by downstream projects for their own byte limiter implementation.

In Cortex, we implmented a token bucket based limiter. We noticed that when calling indexCache.FetchMultiPostings and fetching a lot of keys, bytesLimiter.ReserveWithType can consume a lot of CPU because our implementation requires holding a lock. This was around 40% of the whole CPU time spent on indexCache.FetchMultiPostings.

image

This can be optimized by calling bytesLimiter.ReserveWithType only once for the total posting size instead of one call per cached item.

Verification

Existing tests should still pass.

Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@saswatamcode saswatamcode merged commit 6e29530 into thanos-io:main Jan 5, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants