Reduce Parquet cache heap pressure with smaller row-group records [databricks] #16633
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 615 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.384
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #16633"
general
weight: 0.35
gerashegalov
Fixes #16362.
Stacked on #16620.
Description
Large
ParquetCachedBatchrecords can exhaust the JVM heap when Spark reloads cached partitions. Spark deserializes whole records and can retain a large number of them per task before checking its memory budget. The java serialization process can retain even more of them.This change uses an 8 MiB uncompressed target for cache records while keeping larger GPU processing batches. We cap the row group size to 8 MiB, or so on both the CPU and the GPU when using PCBS. We then split the files apart by row group when writing and stitch them back together again for reading. This allows us to not lose much performance and still be fast.
The target is internal. No Spark changes or user configuration changes are required. The GPU target is soft because cuDF's page-fragment granularity can produce larger row groups.
Validation
Fresh Spark 3.5.5 build and tests:
Performance
Spark cluster benchmarks used Spark 3.5.6, RAPIDS 26.12.0-SNAPSHOT, and SF3000 Parquet decimal datasets. Each configuration ran five separate Spark applications, with one measured iteration per query and no warmups.
| Workload | Baseline mean | Patched mean | Runtime change |
|---|---:|---:|---:|
| TPC-DS | 235.0 s | 234.8 s | -0.09% |
| TPC-H | 381.0 s | 382.0 s | +0.26% |
Both overall differences were smaller than the observed run-to-run variation. All 1,270 query executions completed successfully. No individual query difference was statistically significant after Holm correction within each workload. Five applications per configuration provide limited sensitivity to small changes.
Manual cache reproduction
Local Spark 3.5.5 runs used an AMD Ryzen Threadripper PRO 5975WX (32 cores / 64 threads) but only 16 cores being used, a JVM heap of 50 GiB, off heap limited to 32 GiB and an NVIDIA RTX A6000 with 48 GiB GPU memory.
The query is the same one that exposed the incorrect partitioning metadata fixed by #16620:
CPU/GPU selects whether RAPIDS execution is enabled. The serializers are Spark's DefaultCachedBatchSerializer and ParquetCachedBatchSerializer.
All times below are milliseconds. "First" includes cache construction; the remaining columns read the populated cache.
| JAR | Execution | Serializer | First | Read 1 | Read 2 | Read 3 | Read 4 | Read 5 |
|---|---|---|---:|---:|---:|---:|---:|---:|
| New | CPU | Default | 139,375 | 12,040 | 12,662 | 12,901 | 16,110 | 13,842 |
| New | GPU | Default | Heap OOM | — | — | — | — | — |
| New | CPU | PCBS | 322,471 | 190,511 | 191,508 | 191,235 | — | — |
| New | GPU | PCBS | 33,786 | 5,823 | 5,624 | 5,725 | 5,726 | 5,387 |
| Old | CPU | Default | 113,429 | 12,547 | 12,631 | 13,341 | 12,576 | 13,772 |
| Old | GPU | Default | Heap OOM | — | — | — | — | — |
| Old | CPU | PCBS | Heap OOM | — | — | — | — | — |
| Old | GPU | PCBS | 30,992 | 6,373 | 6,194 | 5,865 | 5,958 | 6,193 |
The patched CPU PCBS run completed where the old version exhausted the heap. CPU PCBS remains much slower than the default CPU cache. GPU PCBS read times were slightly lower in these runs, but the variation limits conclusions about small differences, particularly cache-fill times.
These manual timings predate the correctness fix in #16620 and were not rerun with it. The final aggregation is small relative to the cache workload, but these measurements are performance observations, not correctness validation.
The Heap OOM using the default serializer was not root caused, but is likely related to larger batch sizes and holding more data in memory to feed the serialization code, but I am not 100% sure on that.
Implementation and tests were developed with AI assistance.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance