Skip unnecessary SparkPlan.clone in GpuOverrideUtil.tryOverride [databricks] #17193
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 · 619 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.385
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #17193"
general
weight: 0.35
firestarman
Fixes #17192.
Contributes to #17191.
why
SparkPlan.clone()is time-consuming.SparkPlan.clone()is not needed in the normal path:- no throw
- failOnError is true
Description
Skip
SparkPlan.clone()inGpuOverrideUtil.tryOverridewhenfailOnErroris true and keeptryOverrideonly at the top-level SparkRule.applyboundaries (GpuQueryStagePrepOverrides.apply,GpuOverrides.apply, andGpuTransitionOverrides.apply). This removes unnecessary full-treeTreeNode.clone()allocations and driver GC pressure during AQE query stage preparation and plan conversion while keeping rule error handling simple and stateless.In a local NDS SF100 A/B benchmark (Spark 3.5.6, Scala 2.12, JDK 17, one NVIDIA L4 GPU,
local[16], 16 GiB driver/executor memory, 8 GiB pinned memory, six concurrent GPU tasks, AQE enabled,spark.rapids.sql.suppressPlanningFailure=false), this eliminates all 7,548plan.clone()calls insidetryOverrideper 103-query stream and reduces cumulativetryOverridetime by 1.333 s (15.6%) per stream.| Metric, mean per complete stream | A: before | B: after | Change |
| --- | ---: | ---: | ---: |
| Cumulative
tryOverridetime, nested calls counted once | 8.536 s | 7.202 s | 1.333 s lower (15.6%) ||
plan.clone()calls insidetryOverride| 7,548 | 0 | Eliminated in this configuration || Sum of timed
plan.clone()call durations | 2.039 s | 0 s | 2.039 s lower || Whole-JVM GC pause time | 2.669 s | 2.428 s | 0.241 s lower (9.0%) |
| Power Test Time | 344.5 s | 344.0 s | 0.5 s lower (0.15%) |
| Sum of the 103 query times | 342.595 s | 342.697 s | 0.103 s higher (0.03%) |
Benchmark notes:
tryOverrideimplementation from730ebf0b50; B: benchmarked on an earlier prototype using the samefailOnError=truezero-clone path (the final commit45b809989keeps the same zero-clone path and removes nestedtryOverridechecks altogether).Completedwith GPU plans confirmed in event logs; this checks completion rather than CPU/GPU result parity. End-to-end SF100 runtime was essentially unchanged, and whole-JVM GC pause time includes work outsidetryOverride.System.nanoTime()instrumentation (not part of the PR) summed only outermosttryOverrideinvocations across the driver lifetime.How it works:
failOnError(TEST_CONF || !SUPPRESS_PLANNING_FAILURE) before cloning and store the backup in anOption[SparkPlan](NonewhenfailOnErroris true,Some(plan.clone())only when failure suppression is enabled).GpuOverrideUtil.tryOverridefromGpuOverrides.applyWithContextup toGpuOverrides.applyand narrowapplyWithContexttoprivate[rapids], matchingGpuOverrideUtil.withActiveSessionplacement soGpuQueryStagePrepOverrides.applyno longer invokes a nestedtryOverride.tryOverridealso ensures that whenSUPPRESS_PLANNING_FAILURE=trueand an inner override fails during AQE query stage preparation, the exception propagates toGpuQueryStagePrepOverrides.apply, skipsDriverlessBroadcastStage.tagEligibleBuilds, and returns the clean untagged fallback clone rather than a partially tagged plan; under defaultfailOnError=true, it also avoids duplicateERRORlogs.FileSourceScanExecMetaBasetransition overrides keep their owntryOverrideboundary.Validation:
45b809989:git diff --check,scalastyle-all-modules, andpython3 build/check_shim_compatibility.py review --base-ref origin/main --head-ref HEAD(PASS, 0 new findings and 0 base findings across 34 buildvers againstorigin/mainca4c1529d).-Dbuildver=356)testsbuild andGpuOverrideUtilSuitepassed on45b809989(7/7 tests passed, 0 failures, 0 skipped).AI assistance was used to prepare this implementation, tests, and description.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance