perf: start the next local partition when a running one finishes #7693
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 · 616 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 #7693"
general
weight: 0.35
viirya
Which issue does this PR close?
Part of #6499. Follow-up to #6883, found while benchmarking #7692.
Rationale for this change
A local query runs at most as many partitions at once as Spark runs tasks. Under the current scheduler, the next partition starts only when the first undelivered one is delivered. So a partition that finishes before its turn keeps its slot until it is delivered, and one slow partition leaves the slots behind it idle. Spark instead starts the next task whenever any task ends.
Range partitions are uniform, so this rarely shows with the ranges #6883 admits. Scan partitions are not: their splits differ in size and some read a file footer. With #7692, collecting a Parquet scan of 320 small partitions on
local[8]took about 45% longer locally than with ordinary Comet. Per-partition timing of that case showed:What changes are included in this PR?
spark.driver.maxResultSize). Without this bound, finished partitions could pile up their batches behind a slow one; in the experiment without it, up to 57 were waiting at once.local-execution.mddescribes the new rule.How are these changes tested?
native/local:-
a_partition_that_finishes_before_its_turn_gives_up_its_slot: while the first partition runs, each later partition that finishes drops its stream and lets the next one start.-
finished_partitions_wait_for_their_turn_within_the_read_ahead_limit: with no read-ahead, a finished partition does not let a partition start beyond those that may run at once.partition_order_runs_at_most_the_given_number_of_partitionsandpartition_order_follows_a_changing_running_limit. They now use partitions that run until the test lets them finish, so the bound is checked against running partitions. The first also replacespartitions_from_a_start_function_are_planned_as_they_start, since it plans its partitions with a start function.a_partition_that_finishes_before_its_turn_gives_up_its_slotand the rewrittenpartition_order_runs_at_most_the_given_number_of_partitionsfail. The read-ahead test passes either way, since it guards the bound this change adds.Benchmark (
collect,local[8], Apple M4 Max, release build, 8M rows in 64 Parquet files). The "before" build is #7692 and the "after" build is #7692 with this change; the two differ only in the native library, and the runs alternate between them to cancel drift on the machine. The selective filter cases come from three runs of each build at 30 iterations, in the order before/after, after/before, before/after. The other cases come from two full runs of each build at 10 iterations, in the order before/after, before/after. Times are averages in ms, before → after:| Case | Partitions | Spark | Comet | Comet local |
|---|---|---|---|---|
| Selective filter (8K rows returned) | 320 | 94 → 91 | 71 → 71 | 96 → 39 |
| Selective filter (8K rows returned) | 8 | 65 → 63 | 33 → 33 | 31 → 31 |
| All rows | 320 | 1158 → 1237 | 1097 → 1154 | 1108 → 1059 |
| All rows | 8 | 1258 → 1330 | 1116 → 1199 | 1051 → 1227 |
| All rows, half in one file | 8 | 1713 → 1674 | 1556 → 1426 | 1140 → 1056 |
| Range, all rows | 8 | 527 → 510 | 534 → 490 | 423 → 449 |
| Range, selective filter | 8 | 9 → 8 | 15 → 16 | 16 → 15 |
Spark and ordinary Comet do not run the code this change touches, so their columns show the noise between runs. With many small partitions, local execution goes from about 35% slower than ordinary Comet to about 1.8x faster, and that case varied by less than 3 ms across runs. The other cases move within the noise that Spark and ordinary Comet show. The largest move is local execution of all rows over 8 partitions, but its single runs ranged from 964 to 1283 ms, and with 8 partitions all of them start at once, so this change does not alter their scheduling.
CometLocalExecutionSuitealso passes (35 tests) with this change applied on top of #7692.