← Back to Pull requests

[FEA] Coalesce small GPU batches after Iceberg scans #16943

Closed
unknown closed this pull request without merging on Nov 26, 2026 04:12 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 07:41 UTC
Author

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 GpuCoalesceBatches after 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 id and the directories supply the identity column p, 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 bare SELECT p collected 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 + 1 also 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 only id. Iceberg supplied p from 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 db81d1d92c with 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 comparison

AI assistance was used to implement the change, run local validation and prepare this description.

Checklists

Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 555 lines (+416 / -139) across 6 files Reviewer: res-life Review duration: 14190m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19% · Safe to merge
    19%