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

Store/Receivers: Calculating chunk hashes on stores/receivers #5703

Merged
merged 16 commits into from
Oct 25, 2022

Conversation

pedro-stanaka
Copy link
Contributor

@pedro-stanaka pedro-stanaka commented Sep 19, 2022

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

Related to #5682

Changes

  • Change multiple implementations of Series() in store to pre-calculate hashes for faster deduplication on querier:
    • TSDB
    • Prometheus
    • Block storage

Verification

pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/bucket_test.go Outdated Show resolved Hide resolved
pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/tsdb_test.go Outdated Show resolved Hide resolved
@pedro-stanaka pedro-stanaka marked this pull request as ready for review September 20, 2022 10:35
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.

Looks good! Just one nit - I would remove request field - I think we want to always offload hash to stores.

pkg/store/storepb/rpc.proto Outdated Show resolved Hide resolved
@@ -122,6 +122,9 @@ message SeriesRequest {
// shard_info is used by the querier to request a specific
// shard of blocks instead of entire blocks.
ShardInfo shard_info = 13;

// Control whether the store should calculate the checksum/hash of chunks
bool calculate_chunk_checksums = 14;
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this and control that in the implementations (each server option for all requests). I don't see a need for request to ask for it explicitly 🤔

Copy link
Contributor

@yeya24 yeya24 Sep 20, 2022

Choose a reason for hiding this comment

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

On the Thanos side I think we can always enable it. But Cortex also relies on the store gateway and the store API . Calculating hash on the cortex side is unnecessary for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please let me know what is best here. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to have it as a command-line argument instead of adding it to the request itself. That's what @bwplotka had in mind I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Umm yeah, sounds like a flag on store gateway is better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I got this right, we would need still to let them pass an option here: https://github.com/cortexproject/cortex/blob/d4fceb1172fff9ac332e525086d07f2ef182aefc/pkg/storegateway/bucket_stores.go#L484, right? Should I create a field on the bucket store to set wether or not to calculate hashes? Then, they could write a BucketStoreOption func that allows them to set this field. Let me know if this is okay.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late reply. For me I think it is fine to add it at blockSeries to control that option. Do you think it works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that, I just thought that since that is a private function of the package they were not able to call it themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah you are right sorry. So we need either:

  1. an option at BucketStore to turn on/off chunk hashing
  2. modify series request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please recheck @yeya24 , I went with my idea to create a BucketStoreOption and enabled it by default on thanos side.

pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/bucket.go Outdated Show resolved Hide resolved
yeya24
yeya24 previously approved these changes Sep 23, 2022
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/store/prometheus.go Outdated Show resolved Hide resolved
@@ -122,6 +122,9 @@ message SeriesRequest {
// shard_info is used by the querier to request a specific
// shard of blocks instead of entire blocks.
ShardInfo shard_info = 13;

// Control whether the store should calculate the checksum/hash of chunks
bool calculate_chunk_checksums = 14;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't need to change the protobuf file, then seems it is also okay to not add any flags.
Since Cortex only shares the store gateway with Thanos, so as long as the blockSeries method exposes a boolean param to control not calculate hash then it is fine. On the thanos side, we can make it always true.

yeya24
yeya24 previously approved these changes Sep 26, 2022
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

LGTM

@douglascamata
Copy link
Contributor

@pedro-stanaka can you push an empty commit please to retrigger the CI? I think something happened to Github Actions and they didn't run after your last push.

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
…ashes

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
pedro-stanaka and others added 12 commits October 14, 2022 18:11
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

fixing flaky e2e tests

Signed-off-by: Pedro Tanaka <pedro.tanaka@legal.one>

fix integration test for prometheus

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Final fix on error linting

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
@pedro-stanaka
Copy link
Contributor Author

@pedro-stanaka can you push an empty commit please to retrigger the CI? I think something happened to Github Actions and they didn't run after your last push.

Hey Douglas. Thanks for taking a look at this. I rebased and fixed some errors regarding new code from main, should be fine now.

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

This looks good. Should we merge it?

Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

LGTM

@GiedriusS GiedriusS merged commit 2d0407f into thanos-io:main Oct 25, 2022
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

Now we need to start using this here ;P

fpetkovski pushed a commit to fpetkovski/thanos that referenced this pull request Oct 25, 2022
…-io#5703)

* Adding hashes to raw chunks and populating it from bucket store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding flag on SeriesRequest to control whether to calculate or not hashes

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Only calculate hash on series request for bucket when needed

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* implement e2e test for prometheus store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

fixing flaky e2e tests

Signed-off-by: Pedro Tanaka <pedro.tanaka@legal.one>

fix integration test for prometheus

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* calculating hash on TSDB Series() request as well

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Final fix on error linting

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using sync.Pool to avoid gc pressure

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing whitespace

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing nit on proto

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing hashpool

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using pool from callee instead of inside helper function

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Reusing the hasher pool in other places

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Calculating hashes by default

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adjusting e2e and integration tests

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* fixing linting and e2e test

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Fixing new call format for tsdb.NewHead

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding option to control whether to hash chunks on stores or not

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
GiedriusS pushed a commit to vinted/thanos that referenced this pull request Oct 31, 2022
…-io#5703)

* Adding hashes to raw chunks and populating it from bucket store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding flag on SeriesRequest to control whether to calculate or not hashes

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Only calculate hash on series request for bucket when needed

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* implement e2e test for prometheus store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

fixing flaky e2e tests

Signed-off-by: Pedro Tanaka <pedro.tanaka@legal.one>

fix integration test for prometheus

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* calculating hash on TSDB Series() request as well

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Final fix on error linting

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using sync.Pool to avoid gc pressure

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing whitespace

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing nit on proto

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing hashpool

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using pool from callee instead of inside helper function

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Reusing the hasher pool in other places

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Calculating hashes by default

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adjusting e2e and integration tests

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* fixing linting and e2e test

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Fixing new call format for tsdb.NewHead

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding option to control whether to hash chunks on stores or not

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
ngraham20 pushed a commit to ngraham20/thanos that referenced this pull request May 18, 2023
…-io#5703)

* Adding hashes to raw chunks and populating it from bucket store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding flag on SeriesRequest to control whether to calculate or not hashes

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Only calculate hash on series request for bucket when needed

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* implement e2e test for prometheus store

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

fixing flaky e2e tests

Signed-off-by: Pedro Tanaka <pedro.tanaka@legal.one>

fix integration test for prometheus

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* calculating hash on TSDB Series() request as well

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Final fix on error linting

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using sync.Pool to avoid gc pressure

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing whitespace

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing nit on proto

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Fixing hashpool

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Using pool from callee instead of inside helper function

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Reusing the hasher pool in other places

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Calculating hashes by default

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adjusting e2e and integration tests

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* fixing linting and e2e test

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Fixing new call format for tsdb.NewHead

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

* Adding option to control whether to hash chunks on stores or not

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
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.

6 participants