Skip to content

perf(core): prefetch the next row group while the current one decodes - #1003

Draft
yihua wants to merge 1 commit into
apache:mainfrom
yihua:perf/row-group-prefetch
Draft

yihua wants to merge 1 commit into
apache:mainfrom
yihua:perf/row-group-prefetch

Conversation

@yihua

@yihua yihua commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

closes #999

Description

The parquet base-file reader fetched a row group's column chunks only after the previous row group was decoded. PrefetchingReader, an AsyncFileReader wrapper, now starts fetching the next selected row group's chunks in a spawned task while the current one decodes. It learns the columns from the reader's own requests (under a row filter, only the filter stage's), serves only ranges a prefetched chunk fully contains, and falls back to a normal fetch when a prefetch fails. It stays at most one row group ahead and aborts in-flight work on drop; on a current-thread runtime the overlap is limited to when the consumer yields.

Impact: TPC-H Q6 at SF100 on S3, read through DuckDB's hudi extension, went from 7.49-7.62 s to 6.51-6.59 s at 16 threads (-13%) and from 3.99-4.16 s to 3.76-3.85 s at 32 threads (two alternating runs each, same instance). The 22-query SF10 S3 total moved within run-to-run noise (warm median 38.1 s to 37.5 s).

How are the changes test-covered

  • N/A
  • Automated tests (unit and/or integration tests)
  • Manual tests
    • Details are described below

Tests in tests::prefetch check that prefetched reads match unprefetched ones, and cover row filters, page-index selections, row-group selection, buffer retention and failed prefetches.

The parquet stream asks for a row group's column chunks only after it
has finished decoding the previous one, so a base-file read never
overlaps a fetch with decoding.

PrefetchingReader wraps the AsyncFileReader under the stream. It maps
each request to the row group and leaf columns it falls in, and starts
fetching the full chunks of those columns for the next selected row
group in a spawned task. Under a row filter it learns only the filter
stage's columns, since the stream fetches the rest only for groups where
a row survives. A request is served from a prefetched chunk only when
the chunk holds the whole range, and a failed prefetch falls back to a
normal fetch. It stays at most one row group ahead and aborts any task
in flight when dropped. On a current-thread runtime the prefetch runs
only while the consumer yields, so the overlap there is limited.

AbortOnDrop moves to util::concurrency so the reader and the write path
share it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefetch the next row group while the parquet base-file reader decodes the current one

1 participant