Repository navigation
feat(query): build stored outputs built in a QueryRun on first use - #824
Merged
Merged
Conversation
This was referenced Oct 18, 2026
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 20, 2026 20:06
e0beb60 to
8827771
Compare
zzylol
force-pushed
the
feat/query-engine
branch
from
October 20, 2026 23:26
2142441 to
1bdf7e9
Compare
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 20, 2026 23:26
8827771 to
d1feb90
Compare
zzylol
force-pushed
the
feat/query-engine
branch
from
October 20, 2026 23:46
1bdf7e9 to
afa5bc6
Compare
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 20, 2026 23:46
d1feb90 to
9bfa31f
Compare
zzylol
marked this pull request as ready for review
October 20, 2026 23:46
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 20, 2026 23:53
9bfa31f to
185f7db
Compare
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 20, 2026 23:56
185f7db to
a3fa8e0
Compare
A stored output with StoredOutputBuild::QueryRun (materialization MatAtQueryKeptAcrossEvaluations, #509 Example 4's B3) is now executed. The query engine builds its summary state from the pane's raw samples the first time an evaluation needs it, and stores it in the SDS under the same SummaryInstanceKey as stored outputs built in an IngestionRun once the pane is closed. Later evaluations reuse it. - Closure is judged by the ingestion progress snapshotted when the evaluation chose its fetch (bound_raw_sample_windows returns it with the windows and evaluate takes it back), not when the evaluation runs, so a summary state built from an earlier, partial fetch is never stored. - Eviction is by the plan's retention_ms plus one pane, measured from the newest closed pane at or before the watermark, as for IngestionRun outputs. A far-future evaluation no longer stops storing. - One fetch per QueryRun definition covers all its missing panes. - QueryRunStats (built, stored, stored_while_metric_behind, reused) is on /api/v1/status/asap under "query_run". stored_while_metric_behind counts summary states stored while their own metric's newest sample had not reached their end: the watermark is global. - A QueryRun definition whose selector does not build no longer fails the install: its queries are forwarded. SummaryBuild, shared by the precompute and query engines, compiles a definition's build and runs it over one pane's samples. Samples of a metric only QueryRun stored outputs read move the watermark (counted as samples_query_run_only) without being buffered. The backend now declares query_time_results_retained: true, and the startup warning about unbuilt QueryRun outputs is gone. examples/planner-layering-example4-b3.json is a workload for which the Planner selects B3 under the default cost model.
zzylol
force-pushed
the
feat/kept-query-time-results
branch
from
October 21, 2026 00:09
a3fa8e0 to
5780d83
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.
Base: main (#821 merged). Next: #839 (the #814 event-time barrier port).
Part of #837: stored outputs built in a
QueryRun(MatAtQueryKeptAcrossEvaluations) are now built, stored in the SDS and reused. Closes the gap #838 left: a plan with query-run outputs installed, but nothing built them.Why
The Planner can choose to compute a summary at query time and keep it across evaluations (
MatAtQueryKeptAcrossEvaluations; #509 Example 4's B3). The backend declared it could not keep query-time results, so the Planner never selected such a plan. When a deployment has raw data in Prometheus and evaluates often, that plan is the cheapest.What
QueryRun: a stored output withbuilt_at: query_runis bound like an ingestion-built one, to its definition's summary ending atT − offset, with these rules:SummaryInstanceKeyas stored outputs built in anIngestionRun, only once its pane is closed. Closed means its end is at or before the watermark when the evaluation chose its fetch:bound_raw_sample_windowsreturns that snapshot (IngestionProgress) with the ranges, andevaluatedecides with it. A summary state built from an earlier, partial fetch is therefore never stored, even if ingestion closed the pane meanwhile. One read while its pane is still open is built for that evaluation only.retention_msplus one pane, measured from the newest closed pane at or before the watermark, the same as stored outputs built in anIngestionRun. A far-future evaluation therefore neither stops storing nor evicts.QueryRundefinition, one bound raw-sample window covers all its missing summaries, with itsScanlabel matchers./api/v1/status/asapreportsquery_runcounters:built,stored,stored_while_metric_behindandreused. Closure is judged by the global watermark, so a metric read byQueryRunoutputs that lags behind other metrics can have a summary state stored before all its raw samples arrived.stored_while_metric_behindcounts those: the summary state's own metric's newest sample had not reached its end. A per-metric watermark is the follow-up.QueryRunread are not buffered, but they move the watermark (samples_query_run_only), with the same future bound and wall-clock cap as routed samples.QueryRundefinition whose selector does not build no longer fails the install. Its queries are forwarded, the same as on the query side.SummaryBuildcompiles a definition's build and runs it over one coverage's samples. The precompute and query engines share it.query_time_results_retained: true, and feat(query): answer planned instant queries by running the plan's roots #821's startup warning is removed.examples/planner-layering-example4-b3.jsonis a workload (ten series sampled every millisecond, p99 over 5 minutes every minute) for which the Planner selects B3.Key code interfaces added / modified
Before this PR
The backend declared
query_time_results_retained: false. A plan with stored outputs built in aQueryRunwas never selected, and a query reading one would have been forwarded.After this PR
Example 4-B3: the first evaluation at 10 min builds five 1-minute summaries. The first evaluation makes one fetch for
(5, 10 min]. The evaluation at 11 min fetches only(10, 11 min], builds one summary, reuses four, and answers like the Planner's query-time reference.Verification
data_plane/tests/query_run.rs(5 tests), all againstInstallablePlan::query_time_reference:stores_by_the_watermark_the_fetch_was_chosen_at: through the engine, ingestion closes the coverage betweenbound_raw_sample_windowsandevaluate. The summary state ending at 10 min is not stored, and the next evaluation fetches it again. This is the review's repro;counts_outputs_stored_while_their_metric_is_behind.data_plane/tests/sds.rs:query_run_outputs_share_one_definition.data_plane/tests/precompute.rs:query_run_metrics_move_the_watermark,query_run_metrics_are_bounded_like_routed_samples.control_plane/tests/plan_workload.rs:selects_stored_outputs_built_in_a_query_run.cargo test --workspace --lockedpasses.