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

Estimate chunk size on compaction looking at data uncompressed size #9099

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented Apr 11, 2023

What this PR does / why we need it:
At compactedIndex.ToIndexFile we were not computing the size of the chunk correctly. We were looking at the size of the chunk ref. Since the size of the chunk ref is always a bunk of bytes, the chunk meta KB field would always be 0.

KB: uint32(chk.Size()) / (1 << 10),

Instead, we should get the approx KBs by looking at the chunks data uncompressed size. As we do at store.IndexChunk:

approxKB := math.Round(float64(chk.Data.UncompressedSize()) / float64(1<<10))

This PR fixes this.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@salvacorts salvacorts marked this pull request as ready for review April 11, 2023 10:12
@salvacorts salvacorts requested a review from a team as a code owner April 11, 2023 10:12
@sandeepsukhani
Copy link
Contributor

Thanks for noticing the issue and fixing it!

@sandeepsukhani sandeepsukhani merged commit fd5d787 into main Apr 11, 2023
@sandeepsukhani sandeepsukhani deleted the salvacorts/fix-compactor-estimated-chunk-kb branch April 11, 2023 10:32
sandeepsukhani pushed a commit that referenced this pull request Apr 11, 2023
…9099)

**What this PR does / why we need it**:
At `compactedIndex.ToIndexFile` we were not computing the size of the
chunk correctly. We were looking at the size of the chunk ref. Since the
size of the chunk ref is always a bunk of bytes, the chunk meta KB field
would always be 0.

https://github.com/grafana/loki/blob/4e893a0a88b2c8c3ea9d1d8b1037f54d8fb7f1af/pkg/storage/stores/tsdb/compactor.go#L367

Instead, we should get the approx KBs by looking at the chunks data
uncompressed size. As we do at `store.IndexChunk`:

https://github.com/grafana/loki/blob/d405162516be78beb3d0712cfd57256c7873fe78/pkg/storage/stores/tsdb/store.go#L189
(cherry picked from commit fd5d787)
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.

2 participants