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

feat(blooms): Prefetch bloom blocks as soon as they are built #15050

Merged
merged 13 commits into from
Nov 22, 2024

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented Nov 21, 2024

What this PR does / why we need it:

This PR adds a new RPC endpoint to the bloom gateway service. Builders pass the blocks they built to the gateway and it download them async. That way blocks will likely be already present in the gateways at query-time.

This can be enabled setting the per-tenant bloom_prefetch_blocks limit to true.

We are also increasing the gateway download queue from 10K to 100K.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • 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

@salvacorts salvacorts changed the title feat(blooms): Add (unimplemented) PrefetchBloomBlocks to the bloom-gateway service feat(blooms): Add PrefetchBloomBlocks to the bloom-gateway service Nov 21, 2024
@pull-request-size pull-request-size bot added size/M and removed size/S labels Nov 21, 2024
@salvacorts salvacorts marked this pull request as ready for review November 21, 2024 09:39
@salvacorts salvacorts requested a review from a team as a code owner November 21, 2024 09:39
Copy link
Contributor Author

@salvacorts salvacorts left a comment

Choose a reason for hiding this comment

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

LGTM

@salvacorts salvacorts changed the title feat(blooms): Add PrefetchBloomBlocks to the bloom-gateway service feat(blooms): Prefetch bloom blocks as soon as they are built Nov 21, 2024
@pull-request-size pull-request-size bot added size/L and removed size/M labels Nov 21, 2024
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Nov 21, 2024
pkg/bloomgateway/client.go Outdated Show resolved Hide resolved
pkg/bloomgateway/client.go Outdated Show resolved Hide resolved

bqs, err := g.bloomStore.FetchBlocks(
// We don't use the ctx passed to the handler since its canceled when the handler returns
context.Background(),
Copy link
Contributor Author

@salvacorts salvacorts Nov 21, 2024

Choose a reason for hiding this comment

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

Not passing a timeout here since you always need to call the cancel function before returning, which would trigger the download to stop. This is not an issue since when the gateway stops, the queue is closed and any pending block download is stopped.

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

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

LGTM. I'm interested in seeing how this works in practice.

Since prefetch is only ever triggered by the builder, I can think of a few cases where this wouldn't work:

  • Gateways get restarted before they can finish prefetching (either from a rollout, an OOM, or something else)
  • We scale up gateways; new replicas won't be told to prefetch

I'm not sure how much these matter in practice, but this PR is pretty small so I think it's fine for us to give it a shot.

@@ -161,6 +161,40 @@ func (g *Gateway) stopping(_ error) error {
return services.StopManagerAndAwaitStopped(context.Background(), g.serviceMngr)
}

func (g *Gateway) PrefetchBloomBlocks(_ context.Context, req *logproto.PrefetchBloomBlocksRequest) (*logproto.PrefetchBloomBlocksResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need prefetch-specific metrics so we can measure the impact of this? (for example, how many blocks were downloaded via a prefetch)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@salvacorts salvacorts merged commit b406015 into main Nov 22, 2024
58 checks passed
@salvacorts salvacorts deleted the salvacorts/PrefetchBloomBlocks-definition branch November 22, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants