[FEA] Coalesce small GPU batches after Iceberg scans #16943
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 555 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16943"
general
weight: 0.35
res-life
Contributes to #16554. Follows up #16499.
Description
An Iceberg scan can emit one small GPU batch per file when files in the same task supply different constant values. This change requests
GpuCoalesceBatchesafter the scan when the projection includes an Iceberg metadata column or an identity-partition source column. The reader applies per-file values and deletes before the coalescer combines rows up to the configured target size. Queries that also project physical data columns can use the same path.For example, if imported Parquet files store only
idand the directories supply the identity columnp,SELECT length(p)can combine batches before evaluating the expression. The scan checks identity transforms and source field IDs across the table’s partition-spec history. It stops at the first projected identity source, so it covers renames and older specs without constructing a set of IDs or planning files. For a bareSELECT pcollected as rows, the existing planner removes the coalescer directly under the final columnar-to-row conversion. Spark input-file expressions retain the split boundaries they need to read the filename and block offsets.Validation
All 30 supported Spark/Iceberg combinations passed locally with 630 integration cases and 30 runtime-version checks. Iceberg 1.6.1 and 1.9.2 skipped 90 unsupported format-v3 cases. The tests cover all three GPU readers, tables with deletes, and imported files read alongside unpartitioned files after dropping an identity partition field. Three shuffle-free projections check for the coalescer. On tables without deletes,
SELECT id + 1also requires a GPU scan and project and checks that the coalescer is absent. This case passed in all 240 supported combinations of Spark, Iceberg, table format and reader. Enabling coalescing for every nonempty projection made it fail on all three readers. With RAPIDS shuffle enabled, all 78 supported cases passed across four representative combinations. Running the identity regressions against the earlier metadata-only rule (844e8c6fb1) reproduced the missing scan coalescer. Input-file expressions matched CPU on all 32,000 rows across 32 file paths.Performance
On an RTX 5880 Ada with Spark 3.5.9 and Iceberg 1.10.1, I compared the metadata-only rule (
844e8c6fb1) and the identity check (edf2df8f85) on the same upstream tree (7710d46fbb). Each table had 32 imported Parquet files of 1,000 rows, all in one scan task. Every file stored onlyid. Iceberg suppliedpfrom the directory partition. Each median covers 28 timed queries across four fresh JVMs per build, following three warmups per table in each JVM.| Query | Identity values across files | Metadata-only rule median | With identity coalescing | Batches into partial aggregate |
| --- | --- | ---: | ---: | ---: |
| Group by
p, count rows | Different | 287 ms | 137 ms | 32 → 1 || Group by
p, count rows | Same | 91 ms | 91 ms | 1 → 1 || Also sum physical
id| Different | 360 ms | 203 ms | 32 → 1 || Also sum physical
id| Same | 94 ms | 93 ms | 1 → 1 |Both queries reproduced these batch counts with the direct partition-field check. A separate Java 17 measurement on Spark 3.5.9 with Iceberg 1.10.1 and eight identity fields found 440–460 fewer bytes allocated per uncached eligibility check. This check runs once per scan.
The earlier metadata-column benchmark compared upstream
db81d1d92cwith post-scan coalescing using the same file and row counts. Grouping files with different metadata values reduced the partial aggregate input from 32 batches to one. The metadata-only median fell from 374 to 181 ms and the mixed query from 458 to 266 ms. An earlier experiment also compared these workloads with the reader-side implementation. Reader-side comparisonAI assistance was used to implement the change, run local validation and prepare this description.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance