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 4 commits into
apache:mainfrom
kamcheungting-db:feat/parallel-scan-e2e
Open

kamcheungting-db wants to merge 4 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.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, the tests are thorough and compare full rows against independent expectations. left a few comments on benchmark portability and comparison boundaries, plus a couple test gaps around RowGroupMidpoint(), PlanWith, and avro split sizes.

add_iceberg_benchmark(mumbling_bitmap_benchmark)

# Reads real Parquet tables, so it needs the bundle.
if(ICEBERG_BUILD_BUNDLE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this benchmark includes <sys/resource.h> and calls getrusage, which won't build on windows when ICEBERG_BUILD_BUNDLE is enabled. should we guard the target with UNIX?

-if(ICEBERG_BUILD_BUNDLE)
+if(ICEBERG_BUILD_BUNDLE AND UNIX)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I’ll guard the target with ICEBERG_BUILD_BUNDLE AND UNIX, since it depends on getrusage.

int64_t PeakRssKiB() {
rusage usage{};
getrusage(RUSAGE_SELF, &usage);
return usage.ru_maxrss;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on macos ru_maxrss is in bytes rather than kib, so PeakRssKiB() will report 1024x too high when divided by 1024 below. should we normalize it here?

+#if defined(__APPLE__)
+  return usage.ru_maxrss / 1024;
+#else
   return usage.ru_maxrss;
+#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I’ll convert ru_maxrss from bytes to KiB on macOS so the later conversion to MiB is consistent with Linux.

/*max_row_group_rows=*/200));
ICEBERG_UNWRAP_OR_FAIL(auto starts, RowGroupStarts(*written.data_file));
ASSERT_EQ(starts.size(), 12U);
// Valid (increasing, in-bounds) offsets that fall inside row groups, so that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to my understanding the parquet reader assigns row groups by RowGroupMidpoint(), not starts (and the comment at line 224 says starts too). since ExpectParallelMatches merges all contiguous ranges, wouldn't start-based assignment still pass here? should we build boundaries from RowGroupMidpoint(), including a midpoint right on a split boundary, and check which rows each split returns?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right: assignment uses midpoints, and checking the combined rows misses that distinction. I’ll correct the comments and check each split’s exact rows using midpoint-based boundaries, including a midpoint exactly on a boundary.


Result<std::unique_ptr<DataTableScan>> BuildScan(
const std::shared_ptr<TableMetadata>& metadata, const ScanSettings& settings) {
ICEBERG_ASSIGN_OR_RAISE(auto builder, MakeScanBuilder<DataTableScan>(metadata));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of the tests configure PlanWith(executor_) yet. could we add an end-to-end case where planning and reading share the bounded executor_ to check that both still make progress?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll add an end-to-end case where PlanWith(executor_) and the parallel reader share the same bounded pool, verifying completion and the full expected rows.

files.push_back(std::move(written));
}
auto metadata = MakeMetadata(files);
ScanSettings settings{.target_split_size = files[0].data_file->file_size_in_bytes / 3};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we assert anywhere that at least one avro file is actually larger than target_split_size? if it's smaller, the planner returns early on size before checking the format, so EXPECT_FALSE(task->is_split()) would pass trivially.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll ensure at least one Avro file exceeds the split target, assert that precondition, and verify it remains unsplit while the Parquet files are split.

const auto before = ReadCounters();
const auto start = Clock::now();
ICEBERG_ASSIGN_OR_RAISE(auto scan, BuildScan(table, filter));
ICEBERG_ASSIGN_OR_RAISE(auto tasks, scan->PlanFilesStream());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RunSerial uses unsplit PlanFilesStream() while RunParallel uses split and packed PlanTasksStream(), so this measures the whole pipeline change rather than parallelism alone. also read_start excludes initial planning in serial but includes first-group planning in parallel, so should we add a serial PlanTasksStream() baseline and align or drop the read-phase ratio?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current comparison measures the whole scan pipeline. I’ll label that explicitly, add a serial PlanTasksStream() baseline, and drop the read-phase speedup ratio because its timing boundaries differ. I’ll rerun and update the results.

const std::shared_ptr<FileIO>& io,
const Workload& workload) {
const auto table_dir = config.dir / workload.name;
std::filesystem::remove_all(table_dir);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: running with a custom --dir deletes everything under --dir/large or --dir/small, which isn't mentioned in the usage comment. should we document that (or use a unique temp subdir per run)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll create a unique subdirectory for each run under --dir and limit cleanup to that directory.

kamcheungting-db and others added 3 commits December 1, 2026 19:22
…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 <[email protected]>
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 <[email protected]>
…uals

- Provide a shared Arrow CPU-pool executor to the parallel scan
  benchmark and integration tests.
- Add planned-scan regressions where a residual references a column
  dropped from the projection, across format versions and both
  case-sensitivity modes.

Co-authored-by: Isaac <[email protected]>

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.

2 participants