Skip to content

Parquet v3: fill-ratio guard for read coalescing (input_format_parquet_read_min_fill_ratio) - #2946

Draft
ianton-ru wants to merge 12 commits into
antalya-26.8from
feature/antalya-26.8/parquet-read-fill-ratio-guard
Draft

ianton-ru wants to merge 12 commits into
antalya-26.8from
feature/antalya-26.8/parquet-read-fill-ratio-guard

Conversation

@ianton-ru

Copy link
Copy Markdown

Fill-ratio guard for read coalescing in the Parquet v3 reader. This is one independent feature split out of #2181, ported onto antalya-26.8. Only the fill-ratio part of the original change is included.

Prefetcher coalesces nearby column chunk ranges into one read when the gap is below the seek threshold. With a large threshold (remote storage) many such gaps add up: a tiny, scattered column (for example a constant column) drags in the wide columns between its chunks, so a few KB of wanted data turn into hundreds of MB read.

New setting input_format_parquet_read_min_fill_ratio (Double, range 0..1, 0 = off, the default): while extending a task in either direction, Prefetcher stops when including the next range would make the wanted bytes of the task less than this fraction of its span. Gaps below 64 KiB are always bridged, so dense reads are never split. A value outside 0..1 is rejected with BAD_ARGUMENTS. New profile event ParquetPrefetcherFillRatioLimitedTasks counts how many times the guard stopped an extension.

Tests: stateless test 05831_parquet_v3_read_min_fill_ratio reads one constant column from a file with wide neighbouring columns and a large input_format_parquet_local_file_min_bytes_for_seek; it checks that the result is the same and that the profile event is non-zero only with the guard on, and that an invalid ratio is rejected. It passed in the Praktika stateless job on a local aarch64 build.

Related: #2181

Changelog category (leave one):

  • Improvement

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

Add the experimental setting input_format_parquet_read_min_fill_ratio (off by default). The Parquet reader stops coalescing reads through gaps when the resulting read would be mostly unwanted data, which avoids reading neighbouring columns when only a small scattered column is requested.

Documentation entry for user-facing changes

The setting is documented by its DECLARE description in FormatFactorySettings.h.

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)

… guard

Read coalescing bridges gaps shorter than the seek threshold to save requests, but many sub-threshold gaps can accumulate into a task that is almost entirely filler: reading a tiny, scattered column drags in its neighbouring columns and amplifies a few KB of wanted data into hundreds of MB read.

Add `input_format_parquet_read_min_fill_ratio` (0 = off, range 0..1). During coalescing, `Prefetcher` stops extending a task once bridging the next gap would drop its wanted/span fraction below the ratio. Gaps below 64 KiB are always bridged, so dense reads are never split. New profile event `ParquetPrefetcherFillRatioLimitedTasks`.

Ported from the fill-ratio part of #2181

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

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [9f336bc]

ianton-ru and others added 11 commits November 24, 2026 15:04
…ption

The setting description claimed that a coalesced task is never allowed to be less than the ratio wanted. In fact `Prefetcher::fillRatioWouldBreak` evaluates the ratio only for gaps of at least 64 KiB; gaps below that are always bridged, so a task made of many such gaps can be arbitrarily sparse, and when the seek threshold is not above 64 KiB (the default `input_format_parquet_local_file_min_bytes_for_seek` is 8 KiB) the guard has no effect.

Describe the actual behaviour and the precondition instead of an unconditional bound.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…eadManager`

The range check lived in `Prefetcher::init`, which is also used by schema inference, the count-only path and `ParquetBucketSplitter::splitToBuckets`. An out-of-range value therefore made `DESCRIBE` and bucket splitting throw `BAD_ARGUMENTS`, although they never coalesce data reads, while the sibling settings `input_format_parquet_prefetch_memory_fraction` and `input_format_parquet_decode_thread_fraction` are validated only in `ReadManager::init`.

Move the check next to those two, before any read is scheduled, so that equivalent invalid values behave the same.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
… test

The "guard off" check was trivially true (the guard returns early when the ratio is 0), and nothing checked that a dense read is left alone or that the guard really changes the reads issued.

Add a dense read (all columns, no gaps) that must neither be limited nor change the number of reads, and assert that the sparse read with the guard on issues more reads than with the guard off, in addition to the `ParquetPrefetcherFillRatioLimitedTasks` event.

The invalid-ratio check now reads a column (`sum(length(b))`): a plain `count()` takes the count-only path that never reaches the `ReadManager`, where the range check now lives. Also check that an invalid ratio does not break schema inference.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
… filler instead of gap size

`Prefetcher::fillRatioWouldBreak` computed the gap on each side of the task and evaluated the ratio only for gaps of at least 64 KiB, so a task made of many smaller gaps was never limited and the guard did nothing when the seek threshold was not above 64 KiB.

Evaluate the ratio on every extension and exempt only tasks with less than 64 KiB of total filler (span minus wanted bytes). This drops the gap computation, makes the description of the setting accurate (a task is not extended once it is less than the ratio wanted, unless it has little filler), and makes the guard effective at the default `input_format_parquet_local_file_min_bytes_for_seek`.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…et_read_min_fill_ratio`

The previous commit (ffcb741) said the guard is effective at the default `input_format_parquet_local_file_min_bytes_for_seek`. That is wrong. The scan conditions in `pickRangesAndCreateTaskIfNotExists` keep a task within the requested ranges plus `bytes_per_read_task` on each side, so its filler stays below 2 * `bytes_per_read_task` = 8 * `min_bytes_for_seek`. The 64 KiB filler floor can therefore be reached only when the seek threshold is above 8 KiB, and with the default 8 KiB the guard never refuses a task (a probe showed 0 limited tasks at 8 KiB and 51 at 8 MiB).

This commit documents the precondition in the setting description and in the comment on `filler_floor_for_fill_ratio`. It does not change behaviour. The earlier commit cannot be amended, per repository rules.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…ad_min_fill_ratio` description

The description said the guard needs a seek threshold above 8 KiB and named only `input_format_parquet_local_file_min_bytes_for_seek`. That setting is used for local files only. For object storage `ParquetV3BlockInputFormat` uses `read_settings.remote_fs_settings.min_bytes_for_seek`, which `StorageObjectStorageSource` sets to the remote read buffer size (`max_read_buffer_size_remote_fs`, 1 MiB by default, capped at the object size).

Name both thresholds so that the precondition is correct for object storage too. No behaviour change.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…er floor with the read task size

With a fixed 64 KiB filler floor, the guard could never refuse a task when `bytes_per_read_task` is at most 32 KiB. The scan conditions in `pickRangesAndCreateTaskIfNotExists` keep a task's filler below 2 * `bytes_per_read_task`, and `ParquetV3BlockInputFormat` sets `bytes_per_read_task` to 4 * the seek threshold, so at the default local `input_format_parquet_local_file_min_bytes_for_seek` of 8 KiB the guard did nothing. Every previous attempt to document this precondition got a detail wrong, because the description had to restate how other settings determine the threshold.

Use min(64 KiB, `bytes_per_read_task` / 2) as the floor instead. Behaviour is unchanged when `bytes_per_read_task` is at least 128 KiB (seek threshold of 32 KiB or more). Below that, the guard now acts. The setting description no longer depends on other settings or their defaults.

Add a test case with 600 small row groups at the 8 KiB seek threshold. It fails on the previous commit (0 limited tasks, no extra reads) and passes with this change.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…he `EXPERIMENTAL` tier

The description starts with "Experimental.", but the setting was declared with flags 0, so `system.settings` reported `tier = 'Production'`, `allow_feature_tier` did not restrict it, and the docs generator (`experimental-settings.sql`) left it out of the experimental list. Declare it with `EXPERIMENTAL`, as `use_reader_executor` does for the same label.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…_fill_ratio`

- `ParquetPrefetcherFillRatioLimitedTasks` said a refused task would be "mostly unwanted filler", which holds only for a ratio of at most 0.5. It now says the next range would leave the wanted fraction below the ratio.
- The comment on `Prefetcher::fillRatioWouldBreak` had a garbled sentence about the filler floor.
- The test comment called `big` incompressible; it compresses about 5.6 times.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…` in the settings history

The entry said a tiny scattered column "no longer drags in its neighbours". The guard only limits that: a task may still be up to (1 - ratio) filler, and filler below the floor is always allowed. Reword it to "limits how much", using the same terms as the setting description.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>
…istent

- The description used "Range 0..1"; the sibling scheduler settings and the error message in `ReadManager::init` say "Must be in [0, 1]". It also said "Parquet v3" where the siblings say "the Parquet reader".
- It quoted "a few KB ... into hundreds of MB", which was never measured. It now says only that far more bytes are read than the query needs.
- The filler floor was described as "below 64 KiB, or less for small seek thresholds". It is exactly min(64 KiB, 2 * seek threshold), because `bytes_per_read_task` is 4 * `min_bytes_for_seek`. The description now says that, and names the local seek threshold, `input_format_parquet_local_file_min_bytes_for_seek`.
- The inline comment in the left scan said the guard prevents "mostly filler" tasks, which holds only for a ratio of at most 0.5.

Related: #2946
Co-authored-by: Cursor <cursoragent@cursor.com>

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.

2 participants