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

fix(blooms): Reduce jumps between buckets in blocks pool #12362

Closed
wants to merge 1 commit into from

Conversation

salvacorts
Copy link
Contributor

What this PR does / why we need it:
Before this PR the blocks pool would create the following buckets:

  • 1KB... 2MB, 8MB, 32MB, 128MB

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:

if sz > bktSize {
continue
}
b := p.buckets[i].Get()
if b == nil {
b = p.make(bktSize)
}

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:

  • 1MB, 2MB, 4MB, 8MB, 16MB, 32MB, 48MB, 64MB, 96MB, 128MB.

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.

image
image

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

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

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.

1 participant