Skip to content

Parquet: share cached footer metadata between readers - #115877

Closed
adonm wants to merge 15 commits into
ClickHouse:masterfrom
adonm:adonm/parquet-shared-footer-cache
Closed

adonm wants to merge 15 commits into
ClickHouse:masterfrom
adonm:adonm/parquet-shared-footer-cache

Conversation

@adonm

@adonm adonm commented Aug 21, 2026 •

Copy link
Copy Markdown

Related: #116235

Avoid copying a cached Parquet footer into every V3 reader. Readers hold an aliasing shared_ptr to immutable metadata, retaining its lifetime after cache eviction.

The focused dictionary regression now uses three deterministic row groups, disables other filters, compares exact results with an unfiltered read, and requires read_rows = 10000 on a footer-cache hit. It passed against the PR's fbaf0da3 CI binary. The updated head also incorporates the documentation-example fix from #117827; upstream checks on that head are running.

The earlier private sync check reported build failed; its logs are not accessible with my account, so I have asked for the failing file/symbol rather than assuming it is unrelated. Historical measurements in the umbrella issue are not fresh isolated measurements of this head.

Changelog category (leave one):

  • Performance Improvement

Changelog entry:

Share immutable cached Parquet footer metadata between V3 readers instead of copying it for each reader.


Original implementation assisted by DeepSeek V4 Pro; follow-up revisions also used AI assistance.


Workflow [PR]
Sync PR [sync-upstream/pr/115877]

@CLAassistant

CLAassistant commented Aug 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@adonm
adonm force-pushed the adonm/parquet-shared-footer-cache branch from 4b9303c to cb15d53 Compare August 22, 2026 00:29

@rienath rienath left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like AI one-shot. You also filed many PRs simultaneously. Consider creating an issue instead

@adonm

adonm commented Aug 25, 2026

Copy link
Copy Markdown
Author

@rienath thanks for the feedback. I've moved the full context into #116235 (measurements, repro, landing order).

This PR is first in that order, smallest of the six, and the baseline for #115878's numbers.

I'll rebase all six onto master and update here once fork validation is green.

Keep the footer-sharing change current with master.
adonm added a commit to adonm/ClickHouse that referenced this pull request Aug 25, 2026
The cached V3 flow populates only shared_file_metadata, so
prepareBloomFilterCondition and the dictionary-value hashing read an empty
by-value file_metadata member and throw std::out_of_range in
makeColumnDescriptor. Caught by the warm-perf point lookup on the validation
branch. Fix applies to PR ClickHouse#115877 as well.
adonm added 2 commits August 25, 2026 08:05
When the footer comes from the shared metadata cache, the by-value
file_metadata member is empty; prepareBloomFilterCondition and the
dictionary-value hashing then throw std::out_of_range in
makeColumnDescriptor. Found by the warm-perf point lookup on the validation
branch.
…ction

Its file_metadata parameter is legitimately used; only the member-function
bloom-filter path needs getFileMetadata().
@scanhex12 scanhex12 self-assigned this Aug 25, 2026
@scanhex12 scanhex12 added the can be tested Allows running workflows for external contributors label Aug 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3d8499a]

Summary: ✅


AI Review

Summary

This PR changes the Parquet V3 reader to retain footer metadata through shared ownership instead of deep-copying cached footers per reader, and it updates the remaining bloom-filter and dictionary-pruning carriers to read through that shared metadata. The current diff and discussion look consistent with that contract, and the added regression coverage now exercises the cache-hit pruning paths that originally broke.

Final Verdict

✅ No new issues found in the current PR state.

LLVM Coverage Report

Measured on commit 3d8499a.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.10% 81.10% +0.00%

Changed lines: Changed C/C++ lines covered: 94/101 (93.07%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 25, 2026
String etag = object_with_metadata->metadata->etag;
ParquetMetadataCacheKey cache_key = ParquetMetadataCache::createKey(file_name, etag);
return metadata_cache->getOrSetMetadata(
return metadata_cache->getOrSetMetadataPtr(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it was already common as there was a cache, but making metadata as a pointer seems good (as we don't need to copy it anymore)

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3d8499abb with master d1adb9f9f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

20 translation units recompiled, 213 s compile time in total, 20 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +15.0 s (+8%) in total before that adjustment.

Job report

The cached V3 flow leaves the by-value file_metadata member empty, and
the bloom-filter and dictionary pruning paths used to read it, throwing
std::out_of_range in makeColumnDescriptor on the second (cache-hit)
read. This test reads both paths twice and asserts identical results
plus a ParquetMetadataCacheHits on the cache-hit read.
adonm added a commit to adonm/ClickHouse that referenced this pull request Aug 25, 2026
…dation tree

Mirrors the PR ClickHouse#115877 fix; the stateless CI job on the validation branch
will run it.
adonm added 2 commits August 25, 2026 20:31
- tag no-fasttest: the fast-test build has no Parquet format
- add current_database = currentDatabase() to the query_log reads
  (style check)
@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 40 queries analysed

The only flagged query is tpch_adapted_1_official Q17, provisionally an improvement of -34.0%. This PR is scoped entirely to the ParquetV3 reader's file-metadata sharing/caching (making the cached footer a shared_ptr so cache-hit reads reuse immutable metadata) plus a new test. TPC-H Q17 executes against native MergeTree tables and touches no Parquet code path, so a real speedup here is not plausible; combined with the query's noisy history, the delta reads as run-to-run variance. Downgraded to not_sure.

clickbench

🟢 No significant changes

tpch_adapted_1_official

⚠️ 1 inconclusive

Flagged queries (1 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 17 not_sure 100 66 -34.0% <0.0001 This PR only touches the Parquet reader footer-caching path; TPC-H Q17 runs on native MergeTree tables and never reads Parquet, so the -34.0% delta is run-to-run variance on a noisy query, not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 03b03d7f-0c3f-4bf1-878c-8d35c3b32ad5
  • MIRAI run: 3e89d3c5-2c2b-406e-bf43-a9f593a26379
  • PR check IDs:
    • clickbench_1283800_1788599287
    • clickbench_1283812_1788599287
    • clickbench_1283819_1788599287
    • tpch_adapted_1_official_1283828_1788599287
    • tpch_adapted_1_official_1283856_1788599287
    • tpch_adapted_1_official_1283871_1788599287

adonm added 2 commits August 26, 2026 01:48
…the test comment

Reviewer feedback asked for a self-pass over the diff for idiomatic
patterns and redundant comments.
The loongarch64 build compiles without Parquet, where the header is
empty and the test fails with undeclared identifiers.
@adonm

adonm commented Aug 26, 2026

Copy link
Copy Markdown
Author

@rienath upstream CI is fully green on this one, and the fork validation is green as well: full build, all stateless tests, and the warm-perf harness on the public dataset (numbers in #116235). I've also added the regression test the AI review asked for (cached footer + bloom and dictionary pruning) and done a self-review pass over the diff.

@rienath
rienath dismissed their stale review August 26, 2026 15:53

Addressed

adonm added a commit to adonm/ClickHouse that referenced this pull request Sep 3, 2026
Replace debug-only `chassert` guards in `ManifestFilesPruner::partitionFilterHash` with real `LOGICAL_ERROR` checks on the `KeyCondition` `RPN` (`AND`/`OR`/`NOT`), so a malformed stack throws an exception in release builds instead of causing undefined behavior.

Document only, no behavior change: stateless `ManifestFileIterator::create` `table_snapshot_id` placeholder, `ParquetV3BlockInputFormat` row-group key unambiguity via `path.size()`, partition-only candidate sharing between data and delete iterators, derived `StorageInMemoryMetadata` `TableStateSnapshot` equality safety under `SYSTEM CLEAR ICEBERG METADATA CACHE`, and `DatabaseDataLake::tryGetTableImpl` global-context credentials, TTL race, and `ALTER DATABASE` over-invalidation.

Related: ClickHouse#116235
Related: ClickHouse#115873
Related: ClickHouse#115874
Related: ClickHouse#115876
Related: ClickHouse#115877
Related: ClickHouse#115878
@clickhouse-gh clickhouse-gh Bot added the comp-parquet-reader-v3 Issues related to the native Parquet reader. label Sep 4, 2026
adonm and others added 3 commits September 5, 2026 06:25
Pin disjoint row-group dictionaries, disable other pruning paths, compare with an unfiltered baseline, and assert `read_rows = 10000` on the cache-hit read. Verified against the existing PR CI binary.

Related: ClickHouse#115877 (comment)
…eriesPrometheusValueToString

Fix width of `timeSeriesPrometheusValueToString` doc example table (breaks "Docs examples" check)
Includes the documentation example fix from ClickHouse#117827; the strengthened dictionary regression remains in the PR.
@adonm

adonm commented Sep 5, 2026

Copy link
Copy Markdown
Author

🕵 Strengthened the dictionary-pruning regression: three deterministic row groups, other filters disabled, exact results compared with an unfiltered baseline, and read_rows = 10000 asserted on the footer-cache hit. It passes against this PR’s fbaf0da3 CI binary. I also merged master through b633813d, including the docs-example fix from #117827; checks on the updated head are pending.

The previous CH Inc sync status says build failed. My account cannot read the private sync repository. Could a maintainer share the failing file/symbol or take a look at that build? I have not assumed it is unrelated.

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@adonm

adonm commented Nov 9, 2026

Copy link
Copy Markdown
Author

Closing as superseded rather than rebasing.

#124364 (merged 2026-10-20, in 26.11+) now has the metadata cache return a shared cache cell, and readers reference the cached footer through Reader::setFileFooter instead of copying FileMetaData per reader — the same change this PR made, plus per-column chunk parsing. Its description explicitly calls out the conflict with this PR.

A rebase would now be a no-op or a duplicate of merged code, so I'm closing it instead of pushing a branch. The regression coverage requested in review is also largely covered by gtest_parquet_lazy_column_chunks.cpp and the metadata-cache tests that landed with #124364.

Thanks @scanhex12 for the earlier review and the pointer on shared_ptr metadata. Context stays in #116235.

@adonm adonm closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-parquet-reader-v3 Issues related to the native Parquet reader. external Author is not a member of the ClickHouse organization pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants