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

Refactoring: do not pass the chunks pool to newBucketChunkReader() #3611

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented Dec 1, 2022

What this PR does

Currently newBucketChunkReader() requires the chunks pool in input. This complicates the implementation of the streaming store-gateway, so in this PR I'm proposing to remove it and just pass the chunks pool to bucketChunkReader.load() which is where is required. Keep in mind pool.BatchBytes is concurrency safe.

Which issue(s) this PR fixes or relates to

N/A

Checklist

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

Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci requested a review from a team as a code owner December 1, 2022 15:10
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov 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 think we can simplify further.

// save a copy of b's payload to a buffer pulled from chunksPool.
// The buffer containing the chunk data is returned.
// The returned slice becomes invalid once chunksPool is released.
func (r *bucketChunkReader) save(b []byte, chunksPool *pool.BatchBytes) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't have to be a method of bucketChunkReader anymore

Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov Dec 1, 2022

Choose a reason for hiding this comment

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

And even better - what do you think about inlining it in populateChunk? It's simple enough and it's not used elsewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will also move populateChunk() to bucket_chunk_reader.go.

Copy link
Collaborator Author

@pracucci pracucci Dec 1, 2022

Choose a reason for hiding this comment

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

While doing it, I realized that inlining save() logic into populateChunk() makes the code harder to read. I will keep other suggestions tho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See: c2a2039

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I'm happy with what you have. also removing the indirection of passing a func is good enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

…nk() to bucket_chunk_reader.go

Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci enabled auto-merge (squash) December 1, 2022 15:45
@pracucci pracucci merged commit ad526f8 into main Dec 1, 2022
@pracucci pracucci deleted the cleanup-chunk-pool-design branch December 1, 2022 15:48
pracucci added a commit that referenced this pull request Dec 1, 2022
…3611)

* Refactoring: do not pass the chunks pool to newBucketChunkReader()

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Renamed bucketChunkReader.save() to saveChunk() and moved populateChunk() to bucket_chunk_reader.go

Signed-off-by: Marco Pracucci <marco@pracucci.com>

Signed-off-by: Marco Pracucci <marco@pracucci.com>
masonmei pushed a commit to udmire/mimir that referenced this pull request Dec 16, 2022
…rafana#3611)

* Refactoring: do not pass the chunks pool to newBucketChunkReader()

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Renamed bucketChunkReader.save() to saveChunk() and moved populateChunk() to bucket_chunk_reader.go

Signed-off-by: Marco Pracucci <marco@pracucci.com>

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants