refactor(planner): strip in-process planner band-aids; rely on natural plan shape - #6
Closed
mdashti wants to merge 0 commit into
Closed
Conversation
mdashti
force-pushed
the
moe/mpp-skip-grpc-on-unaddressed
branch
from
May 13, 2026 02:54
490af86 to
2b9bf91
Compare
mdashti
force-pushed
the
moe/mpp-in-process-cleanup
branch
from
May 13, 2026 02:55
d3cd758 to
2b9bf91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #4. Strips the in-process planner band-aids that were added to make embedders' single-leader topology work: blanket
consumer_tc=1forcing on Shuffle, Coalesce arm elision, nestedinput_tc=1forcing, thein_processandhas_boundary_ancestorparameters threaded through_distribute_plan.After this PR, in-process mode means exactly one thing to the planner:
prepare_planskips the gRPC dialer (the only legitimate in-process concern, preserved insrc/execution_plans/distributed.rs). Plan shape itself falls out of the annotator's naturaltask_countmath, same as the gRPC path. Peer-mesh emerges fromtask_count > 1at a Shuffle boundary without a flag; gather emerges from the outermost stage naturally gettingtask_count = 1via cardinality reduction.Why this is the right design
Stu flagged on #4 that mixing planner-shape concerns into the transport-plumbing PR confused the review and the underlying problem should be resolved differently. Two pieces of the answer:
emit_peer_shufflesshouldn't be a flag — it's plan-shape, and the annotator already knows how to produce that shape. The flag exists only because the in-process planner over-customizes by forcingconsumer_tc=1everywhere; once you stop forcing, the shape is what you want.AggregateExec(FinalPartitioned). The cut in the plan tree where data exits one worker and enters another is the planner's call; the transport carries bytes between cuts but doesn't materialize them. Multiplexing across one shared substrate is firmly a transport concern (WorkerConnectionalready handles it); fan-out topology is plan-shape.This PR makes the in-process planner say nothing it doesn't have to say.
What changes
Net
-83LOC insrc/distributed_planner/distribute_plan.rs:in_processandhas_boundary_ancestorparameters of_distribute_plan. The function now reads the annotated plan and emits boundaries with the annotator'stask_countdirectly — no in-process branching.nested_in_processvariable and thethis_is_real_boundaryCoalesce special case.consumer_task_count = task_count,input_task_count = max_child_task_count.unwrap_or(1). Same as the non-in-process path.NetworkCoalesceExec(task_count, max_child_task_count)normally; elides only when both are 1.NetworkBroadcastExec(task_count, max_child_task_count)normally; same elision rule.test_in_process_single_boundary_defaultstill passes — the natural shape for that query happens to produce exactly oneNetworkShuffleExec, same as the band-aided shape, because cardinality factors collapse Stage 2 totask_count=1on small data.Embedder impact
Embedders that relied on the band-aided plan shape (e.g. pg_search foundation) get the natural multi-stage plan after this. They need to:
NetworkBoundarynodes, not just the outermost.(stage_id, task_index, partition)matching each boundary's actualoutput_partitioning().partition_count(), not a fixedN.NetworkCoalesceExecas the outermost worker→leader gather, notNetworkShuffleExec(consumer_tc=1, input_tc=N).The pg_search natural-shape adoption is being prepared as a separate PR in that repo.
Test plan
cargo check --workspacecleancargo clippy -p datafusion-distributed --all-targets -- -D warningscleancargo test --lib distribute_plan— 24/24 passcargo test --lib— 191/191 pass (1 ignored)cargo fmt --all -- --checkclean