Skip to content

Parquet v3: add read back-pressure for the compressed prefetch stage - #2977

Draft
ianton-ru wants to merge 2 commits into
antalya-26.8from
feature/antalya-26.8/parquet-prefetch-bandwidth-backpressure
Draft

ianton-ru wants to merge 2 commits into
antalya-26.8from
feature/antalya-26.8/parquet-prefetch-bandwidth-backpressure

Conversation

@ianton-ru

Copy link
Copy Markdown

Part of #2181 (Parquet v3 reader), only the part that is missing from antalya-26.8. The branch already has the ColumnDataPrefetch stage, which lets many row groups download while a few are decoded, and the stage memory fractions input_format_parquet_prefetch_memory_fraction and input_format_parquet_decode_thread_fraction. What it lacks is a back-pressure based on the read throughput.

This adds input_format_parquet_prefetch_bandwidth_hide_seconds. When it is greater than zero, the scheduler stops admitting more ColumnDataPrefetch tasks once the compressed bytes already in flight exceed that many seconds of the measured read throughput. Past that point the storage link is already busy, so more compressed buffering only costs memory. The default is 0, which keeps the current behavior, where compressed prefetch is bounded only by its memory budget.

How it behaves:

  • The Prefetcher counts the bytes of completed reads, and the throughput is the average since init. It is treated as unknown until 1 MiB has been read and 50 ms have passed, and unknown means no throttling.
  • With nothing in flight the check always passes, and the existing privileged-task escape still applies, so the back-pressure cannot deadlock the reader.
  • The new profile event ParquetPrefetchBackPressureStalls counts how often the back-pressure held back a task that the other limits would have allowed.

Limitations: the estimate is an average since init, so throttling lowers the estimate and can tighten itself, which is why the setting is opt-in. The test checks that results are unchanged, that nothing hangs and that the throttle engages. It does not measure the memory or latency benefit on a remote storage with high latency.

Related: #2181

Changelog category (leave one):

  • Improvement

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

Added the setting input_format_parquet_prefetch_bandwidth_hide_seconds for the Parquet v3 reader. When it is greater than zero, prefetching of compressed data stops once the in-flight compressed bytes exceed that many seconds of the measured read throughput. It is disabled by default. Added the profile event ParquetPrefetchBackPressureStalls.

Documentation entry for user-facing changes

The setting is documented in its declaration (input_format_parquet_prefetch_bandwidth_hide_seconds), and the profile event in its description in ProfileEvents.cpp.

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)

UnamedRus and others added 2 commits November 30, 2026 15:03
Add `input_format_parquet_prefetch_bandwidth_hide_seconds`. When it is greater
than zero, the scheduler stops admitting further `ColumnDataPrefetch` tasks once
the compressed bytes already in flight exceed that many seconds of the measured
read throughput. Beyond that point the storage link is already fed, so extra
compressed buffering only costs memory without improving throughput.

The `Prefetcher` now counts the bytes of completed read tasks and exposes
`averageThroughputBytesPerSec` (bytes since `init` divided by elapsed time). The
estimate is reported as unknown (0) until at least 1 MiB has been read and 50 ms
have elapsed, and an unknown estimate does not throttle.

The `ColumnDataPrefetch` stage memory usage is the in-flight compressed bytes, so
`ReadManager::scheduleTasksIfNeeded` compares it, plus the bytes already queued in
the current scheduling pass, against `throughput * hide_seconds`. The existing
privileged-task escape still applies, and with nothing in flight the check always
passes, so the back-pressure cannot deadlock the reader.

The setting defaults to 0, which keeps the previous behavior: compressed prefetch is
bounded only by its memory budget.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ssure

Add the `ParquetPrefetchBackPressureStalls` profile event, incremented each time
`input_format_parquet_prefetch_bandwidth_hide_seconds` holds back a prefetch task that the
memory and thread limits would have allowed. It makes the back-pressure observable.

Add `05818_parquet_prefetch_bandwidth_back_pressure`: a file with 100 row groups is read
with the back-pressure disabled and with a tiny target. Both reads return the same result
without hanging, and only the second one records stalls. A small memory watermark and a
slow consumer make the scheduler run again after the throughput estimate is available.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ianton-ru ianton-ru added antalya performance Antalya Roadmap: Performance port-antalya PRs to be ported to all new Antalya releases antalya-26.8 labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [92921ad]

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

Labels

antalya antalya-26.8 performance Antalya Roadmap: Performance port-antalya PRs to be ported to all new Antalya releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants