Repository navigation
Conversation
…ed computation (#1207 PR 7) A windowed AcrossEvaluations producer read inside an ingestion pipeline or another AcrossEvaluations candidate's computation never delivers: when those contexts run is not known from the memo. Replaces the PR 7 todo.
… ρ_κ c_{κ,v}, h_v and constraint (R) (#1207 PR 7)
Stage 3 selects per execution: an AcrossEvaluations candidate once
(x^mat_v), a None or OneEvaluation candidate once per context κ that
selects it (x_{κ,v}), every edge per context of its consumer
(y_{κ,u,c,i}, only when an AcrossEvaluations producer delivers on κ).
Contexts are the queries' evaluations (deduplicated by equality), the
ingestion pipelines of refresh windows, and materialized computations.
Constraints (A)-(F) hold per execution; (R) h_v >= need·y prices
retained tumbling windows at π_v. The objective is
Σ W^mat x^mat + Σ ρ_κ c_{κ,v} x_{κ,v} + Σ π_v h_v, costed per execution
by asap-cost; the range under a chain costs nothing (the realizer
bypasses it). Replaces the baseline's per-candidate w_v
(candidate_cost.rs) and its delivers_to_consumer check.
… inexact objective names the plan_cost terms the formulation leaves out (#1207 PR 7) A tumbling-window build is costed with the merge the realizer reads it through (charged in its context when it is not materialized), so its consumers see the merged states. When plan_cost of the realized plan differs from the objective, SearchReport::inexact_objective names the terms the formulation does not encode that the selection meets (memory held for query latency, runs per query, per-request chain builds, the merge over a materialized chain, representative producers, ranges under chains, query-time scans). The objective includes the runtime's request fee, a constant. ObjectiveDiffersFromPlanCost, never constructed, is deleted.
…s: Stage 3 over execution contexts (#1207 PR 7)
…d result; an unexplained objective difference is an error again; held memory only when memory has a cost; slices; execution_costs test (#1207 PR 7)
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 #1236 (PR 6, Stage 3 baseline). Part of #1207 (PR 7 of the order), #1204. Draft; not to be merged on its own (one merge unit, PRs 0–9).
Why
PR 6's baseline charges every candidate a fixed$w_v$ : a query-time candidate was costed once per schedule of every query reaching its group, whether or not they select it (PR 6 spec question 2), and the range under a tumbling-window chain was charged though the realizer builds the chain over the range's input (question 3). The concepts doc §5 and #1204 items 1 and 4 replace this with execution contexts and the retention amount $h_v$ with constraint (R).
What
QueryRecurrence,RangeEvaluation), deduplicated by equality), the ingestion pipelineasap-costgroups ingestion runs), andAcrossEvaluationscandidate's own computation.AcrossEvaluationscandidate, $x{\kappa,v}$ per None/OneEvaluationcandidate and context,AcrossEvaluationsproducerdelivers_onasap_cost::node_usage, plus the runtime's request fee (a constant).DagOfSelectedCandidatesnode per selected execution, so a candidate run in two contexts is two nodes (the realizer keeps them apart).delivers_onforIngestionPipeline/Materializedcontexts (the PR 0todo!): false for a windowedAcrossEvaluationsproducer (times not known from the memo).todo!("#1207 PR 7 …")is implemented (constraint (R);delivers_on).plan_cost: exact on small workloads (test below); otherwiseSearchReport::inexact_objectivenames theplan_costterms the formulation leaves out, and a difference with none of them isErrorSelectingPlan::ObjectiveDiffersFromPlanCost.Not here: (K) accuracy (PR 8), tools/snapshots (PR 9); latency (L) and budgets (B) are out of scope (#1204 items 5, 6).
Representation, rules, enumeration (#1207 (a)/(b)/(c))
delivers_onand retention, and agrees with the MILP on 30 random cost sets × 4 schedules (two queries, two chains) plus PR 6's 100 cases.Notation → code
ExecutionContext(types),ExecutionContexts::contexts(deduplicated by equality, indexed byExecutionContextId);RefreshWindow(RefreshWindowIdindexes them)ExecutionContextVariables::x_materializedExecutionContextVariables::x_in_execution_contextExecutionContextVariables::y_in_execution_context(key: consumer's context,PhysicalEdgeId)ExecutionContextVariables::retention_amountSelectionVariables::{z, t}(input_satisfaction_constraints,producer_selection_constraints,query_coverage_constraints,acyclicity_constraints,utilization_constraints(per execution)retention_constraints;TumblingWindowChainGeometry::retention_need_windowsExecutionCosts::cost_per_second(execution_cost.rs)ExecutionCosts::retention_cost_per_window_per_secondexecution_cost::executions_per_seconddelivers_onper contextExecutionContexts::new(y only whenPhysicalCandidate::delivers_on(memo, κ))How
ExecutionContexts::new: walk from each query output in its evaluation context; an execution inOneEvaluationproducer inAcrossEvaluationsproducer once if it delivers onAcrossEvaluationsexecution's inputs run in its computation context (execution_costs: Kahn's order over executions, one representative producer per input (as PR 6), each execution costed bynode_usageatsolve_selection: build, solve (HiGHS, gap 0), decode one node per execution.select_plan: realize,plan_cost, compare, report.Major algorithm changes
Stage 3 selection over execution contexts
latency[10m](PR 6 plan below): plan_cost 7.25e-3/s; here 6.25e-3/s (one shared DDSketchOneEvaluationin the queries' context).validatechecks it. Tests: per constraint family;the_milp_agrees_with_the_reference_enumeration_over_contexts_and_retention;the_objective_equals_plan_cost_on_small_workloads(end to end).plan_costwhere the formulation andasap-costdiffer (spec questions).Deleted (replaced in this PR)
candidate_cost.rs(candidate_costs,computations_per_second,scan_window_of)execution_cost.rs(execution_costs,executions_per_second,scan_window_in_context)SelectionVariables::{x, y}ExecutionContextVariablesSelectionInputs::{cost_per_second, entries, delivers_to_consumer}ExecutionContexts+ExecutionCostsFIXED_COST_PER_CANDIDATEinexact termHELD_MEMORY, …)todo!indelivers_on,retention_constraintsObjectiveDiffersFromPlanCostis kept and now used.New abstractions not in #1207 or the doc (pending approval)
All Stage 3 crate-private:
Execution { Materialized(PhysicalCandidateId), InContext(ExecutionContextId, PhysicalCandidateId) }: one node of the selected DAG.ExecutionContexts(contexts, refresh windows, executions, edges y may select;output_execution,execution_in,computation_context,input_context).TumblingWindowChainGeometry(width, window count, offset,@anchor, range input;refresh_window,retention_need_windows).ExecutionCosts(incl.representative_producers,uncostable),executions_per_second,scan_window_in_context,objective_of,SolvedSelection::execution_of_node,request_cost_per_second.SelectionVariableskeeps onlyzandt, witht: HashMap<Execution, Variable>(doc:t: Vec), only on cyclic components.OneEvaluationruns only in evaluation contexts; no query output from (IngestionTime, None); a query reading a materialized result directly also boundsInexactObjective::inexact_terms.Spec questions
plan_costvs the formulation (makes the objective inexact; recommend aligningasap-cost, not done here): (a)plan_costruns a not-materialized node once per query reaching it, the formulation once per context; (b) a query-time chain:plan_costbuilds per request of its queries, the formulation (and the runtime's windows refreshed on first read) once per window — they differ wheneverplan_costholds query-time results for query latency; latency is out of scope, so the objective has no such term (every query-time plan with memory cost is inexact).OneEvaluationchain in an evaluation context (free only if no non-chain consumer reads it); scan windows of the selected consumers only.delivers_oninIngestionPipeline/Materialized: returns false (aRefreshWindowIdand aPhysicalCandidateIdcannot be resolved from the memo). Stage 2 offersAcrossEvaluationsonly to builds, whose consumers read them at query time, so no edge is lost today. The doc's table could say so.Lower-PR items (not changed)
ErrorSelectingPlan::SelectedPlanFailedCheckandRejectionCause::{LatencyBoundExceeded, LatencyOverRepeatInterval, OverClusterCapacity}are never constructed; the first's doc mentions budget shares (PR 6/PR 8).RejectionCause::Infeasible's doc still mentions "the catalog's consumer constraints" ((J) deleted) (PR 6).a_free_candidate_nothing_reads_is_not_selectedtest is named for (F) but relies ondelivers_on(fine, unchanged).Key code interfaces added / modified
types memo_candidates.rs, execution_contexts.rs, model.rs, execution_cost.rs, select.rs, report.rs
Usage (end to end;
crates/planner/tests/execution_contexts.rsat 8a466a4):Before this PR
Per-candidate fixed$w_v$ ; a None result shared across differently scheduled queries was one node costed for all schedules; chain retention fixed at its window; every plan reported inexact with one generic term.
After this PR
Representative plans (cost model 1 defaults;
fixed_interval_at10 min, phase 0; 1,000 series at 1 s); MILP size and solve time:Compared with PR 6 (#1236 body): p99+p50 10m 7.25e-3 → 6.25e-3/s (one DDSketch
OneEvaluationshared in the context); p99 60m raw retained 3.829e-2 → 3.844e-2/s (DDSketch alpha 0.1 → 0.005: the two tie in the objective, which leaves out held memory — spec question 2); the other two unchanged. MILP sizes 88/88, 374/372, 522/521, 78/76 → 78/110, 314/394, 452/565, 60/78 (variables/constraints).Verification
cargo fmt --all;cargo clippy --workspace --all-features --all-targets -- -D warningsclean;crate_graphpasses (in integration-tests).contexts_are_deduplicated_by_equality,a_not_materialized_candidate_runs_once_per_context_that_selects_it(a_one_evaluation_result_is_shared_within_its_context,two_queries_at_phases_0_and_5_s_read_one_5_s_chain(Stage 3 MILP: implement the formulation variables x, y, z, t and rows (A)–(I) as named code over explicit edges #1204 regression;delivers_onper context),a_chain_retains_what_its_most_demanding_consumer_reads((R), 6 vs 11 windows),a_chain_reads_its_inputs_in_its_own_computation_context(chains_at_ingestion_share_the_pipeline_of_their_refresh_window(execution_costs_follow_the_context_of_each_execution(the_milp_agrees_with_the_reference_enumeration_over_contexts_and_retention; PR 6's (A)–(F) tests adapted. types:delivers_oncases for pipeline/materialized contexts. planner:the_objective_equals_plan_cost_on_small_workloads,held_memory_is_reported_as_an_inexact_term.TimeRangecandidates today); code dedup of per-crate index maps (minor).Test table (
cargo test -p <crate> --all-features --no-fail-fast, at 8a466a4; PR 6: 1330/94/9):Failures: same set as PR 6, except
sharing_issue_regressions::grouped_filtered_quantile_plansnow passes andplanner_fuzz::quantile_rank_witness_prices_from_the_same_sketchis now inconclusive (its witness contains ASAP operators, which Pass 1 refuses — the PR 6 class of 12 fuzz failures, PR 9's tool rework). Each stops where PR 6's did: devtools 37 at PR 9todo!()s, 13 fuzz inconclusive, 2 CLI JSON (PR 9); planner 5 (Pass 2 metric rule / raw data, PR 4 spec question; plans until (K), PR 8; Stage 2 executor-support gap, PR 5); integration 37 (Stage 2 infeasible outputs, PR 5/Pass 1; pinned plan shapes, PR 8/PR 9; θ-less or pre-14 snapshots, PR 9; joint/accuracy-policy, PR 8). No failure isObjectiveDiffersFromPlanCostor stops at a PR 7todo!().