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

Disable chunk trimming in Receivers #7815

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

fpetkovski
Copy link
Contributor

@fpetkovski fpetkovski commented Oct 11, 2024

This change is motivated by the following Slack discussion: https://cloud-native.slack.com/archives/C02KR205UMU/p1728575718863519

When trimming is not disabled, receivers end up recoding all chunks
in order to drop samples that are outside of the range.
This ends up being very expensive and causes ingestion problems during high
query load.

Trimming will be triggered in the following case:

|-------------| chunk
   |-------|        requested range

This commit disables trimming which should reduce CPU usage in receivers.
The engine already skips samples outside of the query range, so correctness will not be affected.

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

Changes

Verification

Start: r.MinTime,
End: r.MaxTime,
Limit: int(r.Limit),
DisableTrimming: true,
Copy link
Contributor Author

@fpetkovski fpetkovski Oct 11, 2024

Choose a reason for hiding this comment

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

Actually both engines will skip samples outside of the range, so we should be safe here. Technically we don't really trim chunks from Store Gateway so the same idea applies there.

@fpetkovski
Copy link
Contributor Author

Forgot to sign DCO and had to force-push.

GiedriusS
GiedriusS previously approved these changes Oct 11, 2024
@pedro-stanaka
Copy link
Contributor

Do we need changelog for this one?

bwplotka
bwplotka previously approved these changes Oct 14, 2024
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Let's double check we are explicitly stating that in Series gRPC API too (that time matcher is "best-effort" to some extend).

I think we already do that in sidecars

@fpetkovski fpetkovski dismissed stale reviews from bwplotka and GiedriusS via 8fcffcb October 14, 2024 09:45
When trimming is not disabled, receivers end up recoding all chunks
in order to drop samples that are outside of the range.
This ends up being very expensive and causes ingestion problems during high
query load.

This commit disables trimming which should reduce CPU usage in receivers.

Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
@fpetkovski
Copy link
Contributor Author

I've extended the godoc on the Series RPC to mention that chunks don't need to be within the exact range. I think this is good enough for now and we don't need a changelog entry because the change is not user facing.

@fpetkovski fpetkovski merged commit 2f39d24 into thanos-io:main Oct 14, 2024
22 checks passed
@yeya24
Copy link
Contributor

yeya24 commented Oct 14, 2024

@fpetkovski Is there a user facing behavior change if we do this? Does it change any of the query results?
Just want to understand if we need a changelog or not.

Actually both engines will skip samples outside of the range, so we should be safe here. Technically we don't really trim chunks from Store Gateway so the same idea applies there.

From this comment I guess there is no user facing changes if we change it?

@fpetkovski
Copy link
Contributor Author

fpetkovski commented Oct 14, 2024

The engine will discard samples outside of the query range, so results are not affected in any way. IMO a changelog entry should not be needed for Thanos users, but we can add one if you still think it is necessary.

@yeya24
Copy link
Contributor

yeya24 commented Oct 14, 2024

@fpetkovski Thanks. If there is no user facing change then let's skip the changelog.
I am wondering if we have any test to capture that this doesn't impact the correctness. Hopefully we don't have any edge case of that.

@fpetkovski
Copy link
Contributor Author

fpetkovski commented Oct 15, 2024

@MichaHoffmann pointed me to the acceptance tests we run from the Prometheus repo itself: https://github.com/thanos-io/thanos/blob/main/pkg/query/query_test.go#L53.

So I think we should be good. Also store-gw has the same behavior which I think hasn't shown any problems so far.

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.

5 participants