fix(blooms): Reduce jumps between buckets in blocks pool #12362
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Before this PR the blocks pool would create the following buckets:
We often read pages that are bigger than 32MB but considerable smaller than 128 MB, still the pool would allocate buffers of 128 MBs for them:
loki/vendor/github.com/prometheus/prometheus/util/pool/pool.go
Lines 61 to 67 in c53457f
In this PR, we copy the pool implementation from prometheus into Loki's pool pkg and add a new method
NewWithSizes
to add sizes that can increase with a factor smaller than 2. That way we can have the following buckets for the blocks pool:We run this in dev, and OOMs were gone. The first wave is before these changes. The second wave is with a factor of 2. The last wave is with the custom sizes.
Special notes for your reviewer:
Maybe copying Prometheus' pool impl and extending it is a bit overkill but I think it makes sense to have a way to configure buckets other than with an exponential factor.
Curiously enough, the prometheus pool impl, doesn't handle well when the factor is smaller than 2: it leads to an infinite loop. So in our imp[l we change the precondition to check that the factor is biggerEq to 2.
Checklist
CONTRIBUTING.md
guide (required)CHANGELOG.md
updatedadd-to-release-notes
labeldocs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR