Repository navigation
perf(planner): compile each stored output's build over the nodes below it - #808
Merged
Merged
Conversation
…w it plan_installable (and Stage 3's executor compile check, through check_compiles) compiled every stored output's build with the whole plan: the executor's compile runs its whole-plan checks (depth, restore, validate) and indexes every node and edge before lowering the build, so a plan of N nodes with S stored outputs cost O(S x N). A pane-expanded plan of a long window has thousands of panes, each a stored output. The first build is still compiled in the whole plan, which runs the executor's whole-plan checks once; every other build is compiled over the sub-DAG of its node and every node below it. check_compiles also looks up nodes and inputs through the index instead of scanning the node and edge lists for each one.
zzylol
force-pushed
the
perf/installable-dag-checks
branch
from
October 21, 2026 10:06
c9befd4 to
4ca2a94
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.
Why
plan_installablecompiled every stored output's build against the whole plan. The executor'scompilechecks the whole plan it is given before lowering anything (preflight_depth,logical::restore,PhysicalASAPDAG::validate) and indexes and sorts every node and edge. For a plan of N nodes with S stored outputs, that is O(S × N).A pane-expanded plan of a long window has thousands of panes, and each is a stored output. On ASAPQuery's seed-862-long workloads the plan has about 5,300 nodes and 1,700 stored outputs.
Since #805, Stage 3 runs the same check (
InstallablePlan::check_compiles) on every candidate that may be selected.check_compilesalso looked up each input node and walked the query run's inputs by scanning the whole node and edge lists, which is quadratic as well. So the long workloads now take 260–420 s end to end, almost all of it in these compiles.Part of #673.
What
check_compileslooks up nodes and inputs through an index built once.How
IndexedDag(built once per plan) also keeps each node's position and each consumer's input edges.IndexedDag::dag_below(root)collects the closure belowrootand returns it as aPhysicalASAPDAGrooted atroot.executor_builds(inplan_installable) andcheck_compilescompile the first stored output over the whole plan, and every other over its sub-DAG.The executor only lowers the nodes it reaches from the roots, stopping at bound inputs, and every node it reaches is in the sub-DAG. So each build compiles exactly as before, and the whole-plan checks still run once per plan.
Key code interfaces added / modified
None (private functions in
crates/planner/src/installable.rs).Usage
A user plans one of ASAPQuery's long-window workloads for a deployment that keeps no raw data (seed-862-long workload-02, its 9 PromQL queries, coverage converter with
--no-raw --failure-probability 0.3):(The numbers come from running the coverage converter. The converter isn't part of this PR.)
Before this PR and after this PR
The 10 seed-862-long workloads (9 PromQL queries each), MVP flags,
plan_installableend to end, release build. Both columns use main with #806 applied locally, so the search itself is fast and what remains is the installable plan's compiles:P41-m87+P1-m3P13-m127+P1-m3P77-m87+P1-m3P41-m87+P1-m3P25-m127+P1-m3P13-m127+P1-m3P77-m87+P1-m3P39-m87+P1-m3P41-m87+P1-m3P41-m91+P1-m3Each workload selects the same plan at the same cost before and after. With this PR, the 20 other ASAPQuery workloads (seed-862 and seed-862-x5) plan in 1.45–1.75 s, at 89–94 MB each.
Verification
cargo test --workspace --locked: passes.installable::tests::stored_output_builds_compile_only_the_nodes_below_them: a p99 panel over a 300 s window every second, with no raw data kept. It plans a DAG of 910 nodes with 300 stored outputs (one-second panes) and counts the nodes handed to the executor's compiler by the stored outputs' builds, in bothplan_installableand Stage 3's compile check (check_compiles).plan_installable's builds reverted to the whole plan: 1,092,000 nodes in 35 s (debug build). The test fails.check_compilesreverted to the whole plan: 281,424 nodes; the test fails./usr/bin/timearound the coverage converter. Selections and costs were compared before and after.cargo fmt --check: passes.