Skip to content

Antalya 26.8: Parquet footer-size hint from Iceberg manifests and reuse of the footer tail - #2950

Draft
ianton-ru wants to merge 3 commits into
antalya-26.8from
feature/antalya-26.8/parquet-footer-hint-and-tail
Draft

ianton-ru wants to merge 3 commits into
antalya-26.8from
feature/antalya-26.8/parquet-footer-hint-and-tail

Conversation

@ianton-ru

Copy link
Copy Markdown

Part of the split of #2181: the Parquet "footer-size hint, plus reuse of that tail" feature.

This is a draft that goes on top of #2949 (the backport of ClickHouse#124883), so the first two commits of this branch are the ones of that pull request. The files changed by this pull request alone are in the last commit. Merge #2949 first; this pull request then shrinks to one commit and can be marked ready.

The v3 reader reads a tail of the file to parse the footer, and the Column Index and Offset Index ranges are read again later, although they are in that tail. On object storage each of these is a separate GET.

  1. Footer-size hint. An Iceberg manifest entry has the number of columns, the file size, the record count and the column bounds, from which estimateParquetFooterSize estimates the footer. The estimate goes through RelativePathWithMetadata::footer_size_hint and ReadOptions::footer_size_hint to Reader::readFileMetaData, which reads the larger of its default tail and the hint when input_format_parquet_footer_read_size is 0. A wrong estimate costs the second read that is needed today, or some extra bytes.
  2. Retained tail. Prefetcher::retainTail keeps the part of the tail that precedes the footer, and a range that lies fully inside it is served from memory with the existing zero-copy cached_region, without a read.

New profile events: ParquetFooterSecondRead and ParquetPrefetcherServedFromRetainedTail.

Differences from the original commits of #2181, because antalya-26.8 already reads a footer tail sized to the file: the hint can only widen that tail (it does not replace it), and the retained part is the one before the footer, which is the part that holds the indexes. The estimator uses 96 bytes per column chunk instead of 64, because the footer of a file written by ClickHouse is about 126 bytes per column (378 KB for 3000 Int32 columns), twice as much as one written by Spark; the row group count is taken from the file size too (128 MiB by default in Iceberg).

Limits:

  • The hint reaches the reader only together with the object's metadata, that is when use_parquet_metadata_cache is on and the ETag can be a cache key. Otherwise the default tail is read, as before.
  • The hint is not serialized for *Cluster functions, so a worker does not have it. The retained tail works on the worker.
  • On a metadata cache hit the footer is not read at all, so neither change has an effect.
  • The retained tail takes memory while the reader lives: at most the first read minus the footer, 2 MiB for object storage unless the hint is larger (the hint is at most 16 MiB).

Tests, run on a local aarch64 build in Praktika (PR CI has not run yet): the new 05814_parquet_retained_footer_tail and integration test test_parquet_footer_size_hint (S3 and local) pass; all 205 stateless tests with parquet and 118 with iceberg in the name pass, except 02841_parquet_filter_pushdown that failed once in the parallel run on a shared file name and passed alone, and 03723_parquet_prefetcher_read_big_at, whose reference changed from 2 to 1 read because a file smaller than the tail is now read in one chunk.

Related: #2181
Related: #2949
Related: ClickHouse#124883

Changelog category (leave one):

  • Performance Improvement

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

Reading Parquet data files of an Iceberg table fetches the footer in one request when its size can be estimated from the manifest, and serves the Column Index and the Offset Index from the footer tail that was already read.

Documentation entry for user-facing changes

Not needed.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

groeneai and others added 3 commits November 23, 2026 16:45
The adaptive footer read (`clamp(file_size / 100, 128 KiB, 2 MiB)`, backported from 115686) saves a round trip on object storage, but for a local file a second read is cheap and the larger tail only costs bytes on every open. `Prefetcher` now records `ReadBufferFromFileBase::isRegularLocalFile`, and `Reader::readFileMetaData` reads 64 KiB when `input_format_parquet_footer_read_size` is 0 and the file is a regular local file. Other sources and an explicit non-zero setting are unchanged.

Cherry-picked from 5a58f22; the setting description and the test follow the 26.8 layout (`05385_parquet_footer_read_size`).

ClickHouse#124883
Related: ClickHouse#124673
Related: #2181
…m master.

The setting description of `input_format_parquet_footer_read_size` now says the 64 KiB tail applies when the file is read directly from the local filesystem (the reader's buffer reports `isRegularLocalFile`). Reads through a file descriptor or a wrapping buffer keep the adaptive size. The `SettingsChangesHistory` reason no longer says that `0` keeps the adaptive behavior.

Cherry-picked from 6fbb4e7; on 26.8 the history reason is in `SettingsChangesHistory.cpp`, so it is changed there.

ClickHouse#124883
Related: #2181
…ter tail

Two changes that make the footer and the page indexes of a Parquet file cost fewer reads on object storage.

1. Footer-size hint. The v3 reader reads a tail of the file to parse the footer (`FileMetaData`) and needs one more read when the footer is larger than the tail. On `antalya-26.8` the tail is 64 KiB for a local file and `clamp(file_size / 100, 128 KiB, 2 MiB)` otherwise, so the footer of a wide file or of a file with many row groups does not fit. An Iceberg manifest entry knows the number of columns, the file size, the record count and the min/max bounds of each column, which is enough to estimate the footer size. `IcebergDataObjectInfo` computes `estimateParquetFooterSize` for a Parquet data file and puts it in the new `RelativePathWithMetadata::footer_size_hint`. `ParquetV3BlockInputFormat` passes it to `ReadOptions::footer_size_hint`, and `Reader::readFileMetaData` takes the larger of its default tail and the hint when `input_format_parquet_footer_read_size` is 0. An explicit non-zero setting still wins. The hint can only widen the first read, so a wrong estimate costs the second read that happens today, or some extra bytes. It reaches the reader with the object's metadata, that is when `use_parquet_metadata_cache` is on and the ETag can be a cache key, and it is not serialized for `*Cluster` functions.

2. Retained tail. The Column Index and the Offset Index are just below the footer, so they are inside the tail that `readFileMetaData` reads. That read went to a local buffer, and the ranges registered later for the indexes were read again, which is another `GET` on object storage. `Prefetcher::retainTail` keeps the part of the tail that precedes the footer, and `pickRangesAndCreateTaskIfNotExists` attaches a range that lies fully inside it to a task that is already `Done` and refers to the retained bytes, with the existing zero-copy `cached_region`. Nothing is retained when the whole file is in memory, or when the footer did not fit into the first read. The tail is written once before the ranges are finalized and is read-only afterwards, so it needs no locking. A file smaller than the tail is read as one chunk and all of its ranges are served from memory, so `03723_parquet_prefetcher_read_big_at` now counts one `ParquetPrefetcherReadRandomRead` instead of two.

New profile events: `ParquetFooterSecondRead` (the footer did not fit into the first read) and `ParquetPrefetcherServedFromRetainedTail` (ranges served from the retained tail).

Tests: `05814_parquet_retained_footer_tail` checks the retained tail with and without a footer that fits. The integration test `test_parquet_footer_size_hint` writes an Iceberg table of 3000 columns with ClickHouse, whose footer is 378 KB, and checks that the default read needs no second read and that a read without the hint needs one, for local and S3 storage.

Related: #2181
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [f6a0b6b]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants