Skip to content

crl-release-26.2: valsep: account for blob-file compression in split-decision size estimate - #6140

Merged
RaduBerinde merged 1 commit into
cockroachdb:crl-release-26.2from
RaduBerinde:valsep-account-for-blob-file-compression-in-split-26.2
Jul 31, 2026
Merged

crl-release-26.2: valsep: account for blob-file compression in split-decision size estimate#6140
RaduBerinde merged 1 commit into
cockroachdb:crl-release-26.2from
RaduBerinde:valsep-account-for-blob-file-compression-in-split-26.2

Conversation

@RaduBerinde

@RaduBerinde RaduBerinde commented Jul 30, 2026

Copy link
Copy Markdown
Member

During a compaction, the size of an output sstable is estimated as keys
are written in order to decide when to split into a new table. When the
compaction preserves existing blob references, the estimate added the
sum of the uncompressed value sizes of the preserved references.

Because blob files are compressed on disk, this overestimated the disk
space the references contribute for compressible data, splitting output
tables earlier than intended and producing smaller-than-target files.
The final stored TableMetadata already accounted for compression via
BlobReference.EstimatedPhysicalSize; only the in-flight estimate used
uncompressed sizes.

ValueSeparator.EstimatedReferenceSize now scales each preserved
reference by its source blob file's compression ratio, using the same
computation as manifest.MakeBlobReference, so the in-flight estimate
converges to the size the table will ultimately report. The source
PhysicalBlobFile is resolved once when a preserved reference is first
created (rather than at FinishOutput) and carried on pendingReference;
the preserved boolean is replaced by a preserved() method that
reports phys \!= nil.

The shared scaling computation is centralized in a new
PhysicalBlobFile.EstimatedReferencePhysicalSize method that performs
the multiplication in 128-bit precision (bits.Mul64/bits.Div64) to
avoid overflow for large blob files.

Co-Authored-By: roachdev-claude roachdev-claude-bot@cockroachlabs.com

…mate

During a compaction, the size of an output sstable is estimated as keys
are written in order to decide when to split into a new table. When the
compaction preserves existing blob references, the estimate added the
sum of the *uncompressed* value sizes of the preserved references.

Because blob files are compressed on disk, this overestimated the disk
space the references contribute for compressible data, splitting output
tables earlier than intended and producing smaller-than-target files.
The final stored `TableMetadata` already accounted for compression via
`BlobReference.EstimatedPhysicalSize`; only the in-flight estimate used
uncompressed sizes.

`ValueSeparator.EstimatedReferenceSize` now scales each preserved
reference by its source blob file's compression ratio, using the same
computation as `manifest.MakeBlobReference`, so the in-flight estimate
converges to the size the table will ultimately report. The source
`PhysicalBlobFile` is resolved once when a preserved reference is first
created (rather than at `FinishOutput`) and carried on `pendingReference`;
the `preserved` boolean is replaced by a `preserved()` method that
reports `phys \!= nil`.

The shared scaling computation is centralized in a new
`PhysicalBlobFile.EstimatedReferencePhysicalSize` method that performs
the multiplication in 128-bit precision (`bits.Mul64`/`bits.Div64`) to
avoid overflow for large blob files.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@RaduBerinde
RaduBerinde requested a review from sumeerbhola July 30, 2026 23:53
@RaduBerinde
RaduBerinde requested a review from a team as a code owner July 30, 2026 23:53
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde
RaduBerinde merged commit 41ad377 into cockroachdb:crl-release-26.2 Jul 31, 2026
7 checks passed
@RaduBerinde
RaduBerinde deleted the valsep-account-for-blob-file-compression-in-split-26.2 branch July 31, 2026 02:08
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.

3 participants