feat(cost): lower and estimate PromQL physical operators - #328
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/cost-query-dag-stack
branch
from
September 2, 2026 19:28
f1a650a to
3d0702a
Compare
zzylol
force-pushed
the
feat/cost-promql-stack-linear
branch
2 times, most recently
from
September 3, 2026 02:54
c402f0b to
f6a62ad
Compare
zzylol
force-pushed
the
feat/cost-query-dag-stack
branch
from
September 3, 2026 02:54
3d0702a to
fa09dcf
Compare
zzylol
marked this pull request as ready for review
September 3, 2026 03:17
zzylol
force-pushed
the
feat/cost-query-dag-stack
branch
from
September 3, 2026 16:07
fa09dcf to
2c86288
Compare
zzylol
force-pushed
the
feat/cost-promql-stack-linear
branch
from
September 3, 2026 16:11
f6a62ad to
9f48885
Compare
zzylol
force-pushed
the
feat/cost-query-dag-stack
branch
from
September 3, 2026 16:29
2c86288 to
0a91fbc
Compare
zzylol
force-pushed
the
feat/cost-promql-stack-linear
branch
from
September 3, 2026 16:29
9f48885 to
72bb94d
Compare
zzylol
force-pushed
the
feat/cost-query-dag-stack
branch
2 times, most recently
from
September 3, 2026 18:47
1307e34 to
228ea1e
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
PromQL range evaluation, subqueries, vector matching, relabeling, series sampling, scalar/vector bridges, info enrichment, per-series functions, and presence functions have different physical work and cardinality rules. Modeling them as relational pass-through nodes either undercounts work or accepts impossible statistics.
The statistics layer also needs the PromQL shape of each physical edge. Rows and decoded bytes alone cannot distinguish a scalar from an instant vector or a range vector, prove evaluation-step consistency, or bound series cardinality.
What
limitkandlimit_ratioseries sampling;series,evaluation_steps, andScalar | Vector | RangeVector.PhysicalOperatorand workload/catalog facts on the matchingOperatorStatisticsvariant.QueryExprnodes into the physical DAG and preserves operation class, operand mode, vector-match cardinality, range/resolution, sampling configuration, and physical child order.Correctness mechanisms
and,or,unless, one-to-one, many-to-one, and one-to-many each enforce their own output bounds.series × evaluation_steps.limitkis bounded per group and is kept distinct from ordered heap Top-K.limit_ratiopreserves its signed ratio exactly.absent/absent_over_timeuse the global synthesized-series bound.present_over_timeuses a separate per-series bound.SourceCoverage; two candidates with different symbolicInfoMatchervalues are not treated as the same comparison scope.HashAggregateis rejected when it attempts to stand in for an unmodeled PromQL cross-series aggregation.Resource formulas
The estimator keeps CPU operations, peak memory, and source reads separate. PromQL nodes add only local work; DAG composition charges shared physical identity once and applies the node's execution multiplicity.
Examples:
input_series × max_window_samples_per_series × sample_width;input_series × accumulator_bytes_per_series;(matching_key_bytes + hash metadata);(key_bytes + hash metadata);The query-time range buffer above is not a tumbling, sliding, pane, or exponential-histogram summary-maintenance window.
Before
PromQL nodes were either unavailable, approximated by generic relational shapes, or validated from a flat set of optional facts. Several paths could lose series/step metadata or apply the wrong cardinality rule.
After
Each supported PromQL algorithm has a typed physical operator, matching statistics shape, lowering rule, semantic validator, and resource formula. Unsupported PromQL shapes fail closed.
Validation
cargo test -p asap-aware-mapping— 281 passedcargo clippy -p asap-aware-mapping --all-targets --all-features -- -D warningscargo fmt --all -- --checkgit diff --checkDepends on #327.