Skip to content

test(scan): Support split and parallel scans - Part-5: end-to-end validation and benchmark - #1168

Open
kamcheungting-db wants to merge 5 commits into
apache:mainfrom
kamcheungting-db:feat/parallel-scan-e2e
Open

kamcheungting-db wants to merge 5 commits into
apache:mainfrom
kamcheungting-db:feat/parallel-scan-e2e

Conversation

@kamcheungting-db

@kamcheungting-db kamcheungting-db commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1167 (Part-4). Review only the last commit: test(scan): Support split and parallel scans - Part-5.

What this PR does

Validates PlanTasksStream() → ParallelScanReader on real tables, and adds a benchmark comparing it with PlanFilesStream() → FileScanTaskReader.

End-to-end tests

New parallel_table_scan_test.cc in the bundled scan_test, for format versions 1–3. Each case compares the parallel rows with the serial path and with independently expected rows, for 1 and 4 workers:

  • multi-row-group Parquet files split by manifest split_offsets
  • missing offsets, which use fixed-size ranges
  • valid offsets that fall inside row groups instead of on their canonical starts; every row is still read exactly once
  • one large row group split into several ranges (no-regression case)
  • many small files packed into groups
  • mixed Parquet and Avro files (Avro stays whole)
  • a case-insensitive residual filter
  • position deletes carried into every split (v2+)
  • absolute _row_id and _pos values across splits (v3)
  • releasing the stream between callbacks while workers are busy

Benchmark

parallel_scan_benchmark (built with ICEBERG_BUILD_BENCHMARKS=ON and the bundle; not run in CI) writes two local tables:

  • large: 4 Parquet files × 2M rows, 125k-row row groups, read.split.target-size = 16 MiB (16 split tasks)
  • small: 400 Parquet files × 2,000 rows

It runs paired, order-alternated serial and parallel trials with the same projection, filter, and batch size, and reports the bootstrapped median and 95% confidence interval of the paired speedup, end to end (scan creation through stream release) and for the read phase. It also reports planning time, queue peaks, producer wait, bytes read, Arrow-pool allocations, and peak RSS. --filter=all-pass (the default) adds a residual that every row passes, so it is evaluated per row; --filter=none omits it.

Results

Release build, 32 hardware threads, local disk with a warm page cache, 10 paired trials, serial versus 8 workers.

Workload Residual filter Serial 8 workers Speedup, 95% CI Before Part-3.5 (#1166)
Large all-pass, per row 0.432s 0.064s 6.72x, [6.49, 6.93] 0.80x (serial 0.834s)
Small all-pass, per row 0.080s 0.017s 4.67x, [4.63, 4.70] 1.12x (serial 0.119s)
Large none 0.257s 0.043s 6.20x, [5.84, 6.29] 6.50x
Small none 0.059s 0.014s 4.24x, [4.21, 4.31] 4.36x

The first two rows were measured with this PR plus Part-3.5 (#1166). Before it, the per-row residual evaluator did not scale across threads (8 workers were slower than one); #1166 removes the per-row Literal construction that caused it.

Worker sweep, large workload with the all-pass filter: serial 0.439s, then 0.418s / 0.234s / 0.142s / 0.078s with 1 / 2 / 4 / 8 workers.

Other measurements, per scan: planning under 2 ms; serial and parallel read the same bytes (327 MiB large, 57 MiB small) with about the same Arrow-pool allocations; the queue peaked at about 1.6 MB and 8 batches, with no oversized admissions and about 2 ms of total producer wait; peak RSS about 1 GB, including writing the tables.

The plan's acceptance rule (lower bound of the 95% interval above 1.0 for the large-file workload) holds with and without a residual filter, given #1166. Timings are not asserted in CI.

Checks

The full ctest suite passes. pre-commit is clean.

Related

Part 1 #976 · Part 2a #1002 · Part 2b #1062 · Part 2c #1065 · Part 3 #1113 · Part 3.5 #1166 · Part 4 #1167.

This pull request and its description were written by Isaac.

…el Arrow reader

Add ParallelScanReader, which reads the groups of a FileScanTaskGroupStream
with a fixed set of workers and returns one Arrow C stream.

- Each worker owns a FileScanTaskReader with residual enforcement forced on.
  Workers claim groups through a planning token: only one calls the group
  stream at a time, outside all locks.
- Completed batches enter an output queue bounded by batch count and by
  charged bytes. Producers are admitted in FIFO order; a batch larger than
  the byte budget is admitted only into an empty queue.
- ArrowBatchSizer charges a batch as the checked sum of its Arrow buffer
  spans, after preflighting offsets, lengths, buffer counts, and every
  layout-dependent size product for overflow. List views and run-end
  encoded arrays are rejected.
- Each task stream's schema is compared with the projected schema before
  its batches are read.
- The first planning, read, schema, or sizing error stops new work,
  releases queued batches, and is reported from get_next as EIO with the
  file and byte range in get_last_error. Releasing the stream between
  callbacks stops and joins the workers.
- iceberg_data now links Threads unconditionally.

Co-authored-by: Isaac <no-reply@databricks.com>
…date

GCC and AppleClang reject a template parameter that shares the member
function's name. Also replace C-style arrays in the batch sizer tests.

Co-authored-by: Isaac <no-reply@databricks.com>
kamcheungting-db and others added 3 commits November 24, 2026 00:34
Use std::cmp_* for signed/unsigned comparisons and std::ranges::is_sorted.

Co-authored-by: Isaac <no-reply@databricks.com>
…idation and benchmark

Plan real tables with PlanTasksStream() and read them with
ParallelScanReader, comparing the rows with PlanFilesStream() and the
serial FileScanTaskReader and with independently expected values, for one
and four workers and format versions 1-3:

- multi-row-group Parquet files split by manifest offsets, by fixed ranges
  when offsets are missing, and by valid offsets that fall inside row
  groups instead of on their canonical starts
- one large row group split into several ranges
- many small files packed into groups
- mixed Parquet and Avro files (Avro stays whole)
- case-insensitive residual filters
- position deletes carried into every split
- absolute _row_id and _pos values across splits (v3)
- releasing the stream between callbacks while workers are busy

Add parallel_scan_benchmark (bundle builds with ICEBERG_BUILD_BENCHMARKS),
which writes a large-file and a small-file local table and reports paired,
order-alternated serial versus parallel trials with a bootstrapped median
and 95% confidence interval of the speedup, end to end and for the read
phase, plus planning time, queue peaks, producer wait, and peak RSS. It is
not run in CI.

Co-authored-by: Isaac <no-reply@databricks.com>
Use std::array for per-path samples and move main's body into the iceberg
namespace instead of a using-directive.

Co-authored-by: Isaac <no-reply@databricks.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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant