Skip to content

Report true uncompressed size for packed skip-index substreams - #109272

Merged
Algunenano merged 5 commits into
ClickHouse:masterfrom
Algunenano:packed-skip-index-uncompressed-size
Jul 7, 2026
Merged

Algunenano merged 5 commits into
ClickHouse:masterfrom
Algunenano:packed-skip-index-uncompressed-size

Conversation

@Algunenano

@Algunenano Algunenano commented Jul 3, 2026 •

Copy link
Copy Markdown
Member

A skip-index substream bundled into skp_idx.packed reported its data_uncompressed_bytes as the compressed size, because the packed archive index stored only the on-disk (compressed) size per virtual file. For highly compressible indexes (a bloom_filter over low-cardinality strings can reach 1000x) this undercounts the uncompressed size by orders of magnitude in system.data_skipping_indices and system.parts, and wrongly suppresses distributed_index_analysis, which gates activation on data_uncompressed via distributed_index_analysis_min_indexes_bytes_to_activate.

The uncompressed size is now recorded in the archive index at write time (the writer already knows it), so it is served from the in-memory index while writing and from the on-disk index on load, without ever reading the payload back. The non-packed layout is unchanged; it still reads the uncompressed size from checksums.txt.

This bumps the packed-archive format to v1 to carry the extra field. The version is chosen per archive, not globally: skp_idx.packed writes v1, while statistics.packed keeps writing v0, so statistics is unaffected by a rolling upgrade. An older server would reject a v1 skp_idx.packed, but packed skip indices are an experimental feature (packed_skip_index_max_bytes), so bumping the format is acceptable. v0 archives (parts written before this change) fall back to reporting the compressed size, as before.

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix data_uncompressed_bytes for skip indices packed into skp_idx.packed (via packed_skip_index_max_bytes): the reported uncompressed size was the compressed size, which also could prevent distributed_index_analysis from activating.

Version info

  • Merged into: 26.7.1.596 (included in 26.7 and later)

A skip-index substream bundled into skp_idx.packed had its
data_uncompressed_bytes reported as the compressed size, because the
packed archive index stores only the on-disk (compressed) size per
virtual file. For highly compressible indexes (a bloom_filter over
low-cardinality strings can reach 1000x) this undercounts the
uncompressed size by orders of magnitude, and wrongly suppresses
distributed_index_analysis, which gates activation on data_uncompressed
via ReadFromMergeTree::get_indexes_size.

Recover the uncompressed size for packed compressed substreams by
walking the compressed block headers (payload skipped, never
decompressed) instead of approximating it as the compressed size. The
non-packed path is unchanged; it still reads the uncompressed size from
checksums.txt.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [549020b]

Summary: ✅


AI Review

Summary

This PR extends skp_idx.packed to persist per-substream uncompressed sizes for packed skip indices and threads that value through MergeTree size accounting, so system.data_skipping_indices, system.parts, and the distributed_index_analysis activation gate all observe the true decompressed size. I did not find a current correctness, compatibility, or testing issue that warrants a new review finding.

Final Verdict

✅ No blocking review findings.

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Jul 3, 2026
@Algunenano

Copy link
Copy Markdown
Member Author

This is failing in the case of writing since the index is not yet finalize. I could hack it, but maybe it's simpler to add the file size to the packed format and bump the version. Having a look

Algunenano and others added 4 commits July 3, 2026 18:55
…uncompressed-size

Resolve conflicts against master's storage refactor (public existsFile /
getFileSize / prepareRead / readFileIfExists now delegate to protected
*Impl overrides, with packed-archive routing centralized in the base
wrapper via getArchiveReaderForFile):

- DataPartStorageOnDiskFull.h: drop the getFileSize override (now
  getFileSizeImpl), keep the new getPackedFileUncompressedSize override.
- DataPartStorageOnDiskBase.cpp: adopt master's copyArchiveEntryTo helper
  and carry the uncompressed size over inside it, so both archive-rewrite
  paths keep v1 accounting.
- IMergeTreeDataPart.cpp: use master's getFileSizeOrZeroResolved with the
  getPackedFileUncompressedSize().value_or(size) recovery.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.60% 85.70% +0.10%
Functions 92.70% 92.70% +0.00%
Branches 77.80% 77.80% +0.00%

Changed lines: Changed C/C++ lines covered: 87/113 (76.99%) · Uncovered code

Full report · Diff report

@Algunenano
Algunenano enabled auto-merge July 7, 2026 12:46
@Algunenano
Algunenano added this pull request to the merge queue Jul 7, 2026
Merged via the queue into ClickHouse:master with commit 5fc031b Jul 7, 2026
175 checks passed
@Algunenano
Algunenano deleted the packed-skip-index-uncompressed-size branch July 7, 2026 13:11
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 7, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…x-uncompressed-size

Report true uncompressed size for packed skip-index substreams
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Nov 3, 2026
…s on 26.6

Since ClickHouse#109272 the skip-index writer emits the `skp_idx.packed` archive in
format 1, which the 26.6 reader rejects with UNKNOWN_FORMAT_VERSION, so the
"stay fully readable on older versions" claim in the entry of ClickHouse#111816 is wrong.
The entry now names the operations that fail on 26.6 and the settings that
keep a rollback to 26.6 possible.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants