Conversation
This was referenced Sep 30, 2026
The backend re-lowered query-time computation itself: it re-parsed PromQL text to recover each operator (query_time::Lower, query_time_nodes and the selected_* witnesses), built QueryTimeOperator Binary/Aggregate/Sort/Limit/ Temporal/Subquery nodes and QueryPlanNode Scalar/Binary/ReduceSum, and translated them into label-map operators (physical_values.rs). The data plane evaluated subquery grids itself. Now the backend lowers only stored-state readouts. The query-time region above them is compiled once by physical_planner::compile, with the readouts as input contracts, into one PhysicalFragment. A root Planner cannot compile over readouts (per-series binaries, comparisons, histogram_quantile, exact selectors under computation) keeps no state and is forwarded whole as ExactFallback, as is any query Planner keeps pre-ASAP. Counter and range-maximum materializations are identified from the selected node, not from query text. The removed operator variants no longer deserialize. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Planner keeps __name__ in the series identity it computes, so a raw-series program for quantile_over_time(0.5, m[5m]) answered with __name__="m", which Prometheus drops. The compiler records on the Physical node whether the query result keeps the metric name (only a selector, through ordering, selection, subqueries and last_over_time does), and the adapter removes it when decoding series identities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out checks Review follow-ups: - A query whose readouts have no maintained state is forwarded whole in every mode; a query that compiled state but cannot bind it fails the candidate instead of maintaining that state unread. Previously a non-mixed deployment failed to compile, e.g. a ratio of two grouped rates whose states were not selected. - Pruned joins read both sides as stored state; a pruned join below a region root is not compiled, since its contract binds only at the root. - An instant count, which has no local exact readout, is not an input to a Planner fragment. - Range-maximum states require a named metric. - first_over_time, filters, relabeling and limitk keep __name__; series that collide once it is dropped are rejected, as PromQL does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The non-mixed ratio test now requires forwarding with no maintained state, a binding failure names its query in the candidate error, and the metric name follows the left side of and/unless. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
refactor/query-side-planner-compile
branch
from
September 30, 2026 09:19
0c9b78d to
c1becfb
Compare
zzylol
added a commit
that referenced
this pull request
Sep 30, 2026
Restores the issue 701/702 warm avg_over_time assertions and the finite-division overflow test that #798 rewrote, and adds control-plane acceptance tests. These fail at the current Planner pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
changed the base branch from
feat/planspace-compile-once
to
refactor/precompute-dag-heaps
September 30, 2026 09:19
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.
Stacked on #800.
Why
Planner's
physical_planner::compilenow covers the query-side computation the backend still lowered itself. The backend re-parsed PromQL text to recover operators, kept its own operator graph (QueryTimeOperatorBinary/Aggregate/Sort/Limit/Temporal/Subquery andQueryPlanNodeScalar/Binary/ReduceSum), translated it to label-map operators, and evaluated subquery grids in the data plane. That is a second lowering of the same computation.What
ReadMaterialization,ExactReadout,SummaryEstimate,SummaryMerge, current series). The query-time region above them is compiled once byphysical_planner::compile, with the readouts as input contracts, into onePhysicalFragment.ExactFallback, forwarded unchanged). Queries that Planner keeps pre-ASAP are handled the same way.query_time::Lower,compile_logical, thequery_time_nodes/selected_*text witnesses,physical_values.rs, theDagCompilerBinary/Logical/Scalar/ReduceSum arms, the computation variants ofQueryTimeOperatorandQueryPlanNode, and the data-plane subquery grid and logical evaluation. Counter and range-maximum materializations are now identified from the selected node.Physical, from feat: bind query-time raw series inputs to the Prometheus endpoint #792) record whether PromQL drops__name__from the result. The adapter removes it when decoding series identities. Planner keeps it.Before / After
sum by (job) (rate(errors_total[5m])) / sum by (job) (rate(requests_total[5m]))Frag[VectorBinary, Project×3, Aggregate×2]built byphysical_valuesfrom re-parsedLogicalAggregate/Binary nodes over twoExactReadoutExactReadout→ one PlannerPhysicalFragment[Join, Project, SummaryBuild, Readout ×2]topk(2, sum by (job) (rate(m[1h])))with an unbindable child: before, Prometheus computed the child and the backend ran topk. After, Prometheus answers the whole query.Startup on the warm test (
collector_free_profile_serves_complete_matrix_and_falls_back_exactly, three runs each): 3.32/3.27/3.24 s before, 3.14/3.09/3.13 s after.Behaviour differences
Binarydoes not yet match per-series rows (coverage Remaining 3). Affected queries were warm before and are now exact:avg_over_time(x[5m])(sum/count),rate(a[5m]) / rate(b[5m]),rate(x[5m]) * 2, andsum_over_time(a[1m]) + sum_over_time(a{job="x"}[1m]). Grouped forms such assum(...) / sum(...)andsum(...) * 2stay warm. The issue 701/702 tests are updated to match.-sum(rate(x[5m]))now runs warm, andmin by (job) (...)and mixed MetricsQL counter queries are now exact.__name__where PromQL drops it.Remaining backend computation
SummaryEstimate/ExactReadout/SummaryMergecomputation inpost_asap_readout.rs(coverage row 16 is Partial; rows 15 and 17 need Planner-typed stored state bindings).storage_engines/sketch_db/current_series.rsare moved in the stacked refactor: compute current-series readouts as Planner physical programs #799.ExactSubquery/CandidateExactSubquery. Their data-plane runtime (exact_subqueries.rs, which re-parses PromQL to inject candidate matchers) is dead for new plans and can be removed in a follow-up.boolcomparisons apart, because the IR does not recordbool. Planner compiles no comparison yet.Validation
cargo fmt --all -- --check,cargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked --lib,cargo test -p control_plane --locked --testscargo test -p data_plane --locked --test asapquery_compatibility_process_e2e -- --test-threads=1(26 passed)__name__. The retired operator variants are rejected.🤖 Generated with Claude Code