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

Stream chunks from blocks-ingester to querier #3889

Merged
merged 13 commits into from
Mar 4, 2021

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented Feb 27, 2021

What this PR does: This PR implements streaming of TSDB chunks from blocks-based ingester to querier. It reuses chunks-based querier, and just introduces new type of chunk: read-only wrapper around TSDB chunk.

State of PR: manual testing shows that it works, unit tests not updated yet.

PR is ready for review. Feature is currently protected by the flag (both CLI and runtime-config to avoid rollout of ingesters when playing with this), but will be enabled by default in the future.

Which issue(s) this PR fixes:
Fixes #3831

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pstibrany pstibrany marked this pull request as draft February 27, 2021 21:18
@pstibrany pstibrany force-pushed the blocks-chunks branch 2 times, most recently from c3b7e3c to 66b47f0 Compare February 27, 2021 21:30
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Mar 1, 2021
@pstibrany
Copy link
Contributor Author

pstibrany commented Mar 1, 2021

Benchmark comparing old (samples based) and new (chunk based) streaming in blocks-ingester.

name                      old time/op    new time/op    delta
Ingester_v2QueryStream-4    6.21ms ± 1%    1.13ms ± 2%  -81.88%  (p=0.000 n=10+10)

name                      old alloc/op   new alloc/op   delta
Ingester_v2QueryStream-4    3.55MB ± 0%    0.36MB ± 0%  -89.92%  (p=0.000 n=10+10)

name                      old allocs/op  new allocs/op  delta
Ingester_v2QueryStream-4     5.66k ± 0%     3.85k ± 0%  -31.88%  (p=0.000 n=10+10)

@pstibrany pstibrany marked this pull request as ready for review March 1, 2021 20:34
@pstibrany pstibrany requested a review from pracucci March 1, 2021 20:34
Copy link
Contributor Author

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

I think this is ready for review now.

}
defer q.Close()

// It's not required to return sorted series because series are sorted by the Cortex querier.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also true for chunks.


// It is not guaranteed that chunk returned by iterator is populated.
// For now just return error. We could also try to figure out how to read the chunk.
if meta.Chunk == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not clear to me if this can actually happen. Needs some investigation.

Copy link
Contributor Author

@pstibrany pstibrany Mar 3, 2021

Choose a reason for hiding this comment

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

@pstibrany pstibrany changed the title [WIP] Stream chunks from blocks-ingester to querier Stream chunks from blocks-ingester to querier Mar 1, 2021
@jtlisi
Copy link
Contributor

jtlisi commented Mar 2, 2021

Fixes #2845

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Wow, very good job! And good tests 👏 I left a couple of nits, but nothing particularly relevant.

pkg/chunk/encoding/factory.go Show resolved Hide resolved
pkg/chunk/encoding/prometheus_chunk.go Outdated Show resolved Hide resolved
pkg/chunk/encoding/prometheus_chunk.go Show resolved Hide resolved
pkg/chunk/encoding/prometheus_chunk.go Show resolved Hide resolved
pkg/ingester/ingester.go Show resolved Hide resolved
pstibrany and others added 12 commits March 4, 2021 09:00
Added tests and benchmarks.

Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
@pracucci
Copy link
Contributor

pracucci commented Mar 4, 2021

Thanks @pstibrany for addressing my feedback! LGTM. I don't feel strong about the double CLI flags considering they're temporarily I'm fine with that.

@pstibrany pstibrany merged commit 5dccf08 into cortexproject:master Mar 4, 2021
@pstibrany
Copy link
Contributor Author

Using this feature makes average time for rule group evaluation to go up:
avg (cortex_prometheus_rule_group_last_duration_seconds)

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.

Transfer encoded chunks from ingesters to querier in the blocks storage
3 participants