Skip to content

Collector views: control plane rule and collector-views file, data plane --collector-views - #891

Draft
zzylol wants to merge 7 commits into
feat/collector-state-ingestfrom
feat/collector-views-file
Draft

zzylol wants to merge 7 commits into
feat/collector-state-ingestfrom
feat/collector-views-file

Conversation

@zzylol

@zzylol zzylol commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: the previous PR (Collector view states: ingest OTLP states of the views a collector builds, staged and committed as the view's windows #890) ingests collector view states, but which views the collector builds is set only through an engine option. Nothing decides it from what the collector can run, nothing tells the collector, and the data plane cannot be pointed at a decision (draft docs(design): plan sub-DAGs precomputed in the collector (v1: leaf sketch views) #885, docs/design/collector-sketch-ingest.md §1 and §2, plan step 4).
  • Change:
    • control_plane::collector_views: the collector's declared capabilities (CollectorCapabilities, what asap_sketches --print-capabilities prints: the planner's DeploymentCapabilities with collector summary entries, predicate ops, operator lines, placement, close delay) and the generic bottom-up rule (a)–(d) of §1 that cuts the collector sub-DAG out of the installed plan (collector_sub_dag).
    • common::CollectorViewsFile: the file both the collector and the data plane load (planner_wire_version, plan_id, backend_reads_raw, outputs, dag in the planner's serde).
    • CLI: control_plane --plan <plan.json> --collector-capabilities <caps.json> --emit-collector-views <out.json> (or with --workload/--out); it prints why each other node is not on the collector.
    • Data plane --collector-views <file>: the file's outputs become the precompute engine's collector views (it skips them and the Scans only they read; views reading them are built from the committed states), and the install is refused when the file's plan_id is not the installed plan's.
  • Effect: for quantile_over_time(0.99, data[5m]) and today's collector, the rule picks exactly the DDSketch chain, marks data as no longer read raw, and the data plane started with the written file answers from the collector's states as it does from its own view. Without --collector-views nothing changes (parity dump byte-identical to the previous PR).

Restack (2026-11-30, 2nd) onto #890 b7b9312, at 40d0d0d

  • No conflicts. Gate on the stack head: clippy -D warnings and fmt clean; storage 53, precompute 12, otlp 18; data_plane collector_views 13, ingest_protocols 6, ingest_shards 17, planner_executor_parity 6, push_precompute 17, result_cache 6, server 10, view_persistence 8, window_levels 4.

Restack (2026-11-30) onto #890 742e799, at f6a3f5f

Restack on #890 8411b5b (2026-11-30), at 5eeb272

Follow-up (2026-11-30, approved), at d324bda

Review guide

Behavior: before → after

Input Before After
control_plane --plan p.json --collector-capabilities caps.json --emit-collector-views cv.json (q01 alone, today's collector) flags unknown writes {"planner_wire_version":16,"plan_id":"…","backend_reads_raw":{"data":false},"outputs":[1],"dag":{…Scan n0, chain n1…}}; prints each node above the chain with its first failing rule, here NotInCapabilities("operator TimeRange"), …SummaryMerge, …SummaryEstimate, …Project
q01 + sum_over_time(data[5m]) — outputs = [q01's chain]; the exact chain is NotInCapabilities("summary ExactAggregate(…)"); backend_reads_raw.data = true
data{job=~"a.*"} — no output: the Scan is NotInCapabilities("predicate op Regex") (data{job="a"} keeps the chain)
Capabilities without DDSketch, or α outside the declared range — no output, the reason names the summary or the parameter
A wider chain level (SummaryMergeWindows) at ingestion — not on the collector (operator SummaryMergeWindows); with {"kind": "SummaryMergeWindows"} added to operators, it becomes a collector view too (the cut moves up)
data_plane --plan p.json --collector-views cv.json flag unknown the chain is the collector's; data samples are not stored
--collector-views of another plan — the data plane refuses to start: the collector views are of plan …, not of the plan installed (…)

Design scope

  • The rule reads planner fields only (decision 6): operator kind and arguments (Scan source and predicates, Filter predicate, chain/SummaryAgg reduction, filter, summary type, input kind and θ), the node's timing, and its reduction against placement. Predicates must be conjunctions of a column compared with a Utf8 literal by a listed op. θ is checked against each declared range by name.
  • Outputs: an assigned node is an output when a consumer is not assigned or it is a query root. A non-Scan output that is not a materialized view is unassigned with every assigned node above it, until none is left (v1, §1). The sub-DAG holds the assigned non-Scan nodes and the Scans feeding one, with the edges between them, roots = outputs; it validates on its own (materialized_views() gives each output's installed key, tested).
  • backend_reads_raw: a metric stays raw when one of its Scans runs at query time, is not assigned, is a root, or feeds a node off the collector.
  • CollectorViewsFile is in common (the design puts it in control-plane): the data plane reads it and depends on common, not on the control plane.
  • The plan check is the engine's: CollectorViewOptions::plan_id is checked by PrecomputeEngine::start, so it holds on every install, not only at startup. (The installer installs the query engine first; at startup a refused install ends the data plane, so nothing serves the half-installed plan.)
  • Operator limits are checked at load: sources only on Scan, reductions only on a chain or SummaryAgg, names must be variants, no kind twice. An Aggregate's grouping is decided by rule (d) alone.
  • Locality (d) is per operator: operators that keep each series' rows to it (Scan, Filter, Project, TimeRange/TimeShift/TimeRangeCover, SummaryEstimate, FinalizeExactAccumulator, SummaryMergeWindows, SummaryMerge without group_by) are local; a grouping is local only under {"labels": L} with L ⊆ G; anything else (joins, binary operators, sorting, limits, populations) is not.
  • Scalar roots count as roots: a node a scalar query reads is an output.
  • The DAG index (inputs, consumers, bottom-up order) is the rule's own: precompute's DagIndex is in the engine crate, which the control plane must not depend on, and the planner's DAG has no traversal helpers.

Deviations from the design document (to fold into #885)

  • collector_sub_dag(plan, capabilities) -> Result<…, InstallablePlanError> (the design: no Result): a plan whose views do not derive, or a cut that does not stand as a DAG, is an error instead of an empty file.
  • CollectorExecutor is deserialized by hand, not with #[serde(flatten)], because DeploymentCapabilities denies unknown fields; the rule reads only its supported_summaries entries today (the planner's DeploymentCapabilities built from them is not needed yet, so no method builds it).
  • control-plane depends on asap-types (the IR the rule reads, which asap-planner does not re-export) and common (the file), not "unchanged".
  • --plan reads a plan written before and only writes its collector views (it needs --collector-capabilities and conflicts with the planning flags).
  • The data plane does not read planner_wire_version (the collector checks it, §3; the plan id covers the data plane) nor backend_reads_raw (the collector's raw-forward filter uses it).

Interfaces

crates/common/src/collector_views_file.rs

+pub struct CollectorViewsFile {
+    pub planner_wire_version: u32,
+    pub plan_id: String,
+    pub backend_reads_raw: BTreeMap<String, bool>,
+    pub outputs: Vec<PhysicalASAPNodeId>,
+    pub dag: PhysicalASAPDAG,
+}

crates/control-plane/src/collector_views.rs

+pub struct CollectorCapabilities { capabilities_version, executor: CollectorExecutor, predicate_ops: Vec<CompareOpKind>, operators: Vec<OperatorCapability>, placement: Placement, window_close_delay_ms: u64 }
+pub struct CollectorExecutor { supported_summaries: Vec<CollectorSummary>, rest: DeploymentCapabilities }  // fn deployment_capabilities()
+pub struct CollectorSummary { summary: SupportedSummary, input: SummaryInputKind, parameters: BTreeMap<String, ParameterRange> }
+pub enum SummaryInputKind { Value, Label }
+pub struct ParameterRange { gt, ge, lt, le: Option<f64> }
+pub struct OperatorCapability { kind: OperatorKind, sources: Vec<String>, reductions: Vec<String> }
+pub struct Placement { partitioned_by: PartitionedBy }
+pub enum PartitionedBy { Series, Labels(Vec<String>) }
+pub enum NotOnCollector { NotInCapabilities(String), InputNotOnCollector, NotAtIngestion, NotLocalToPartition, OutputNotAView, OrderSensitive }
+impl CollectorCapabilities { pub fn from_json(text: &str) -> Result<Self, CapabilitiesError> }
+pub fn collector_sub_dag(plan: &InstallablePlan, capabilities: &CollectorCapabilities)
+    -> (CollectorViewsFile, Vec<(PhysicalASAPNodeId, NotOnCollector)>);

crates/precompute/src/collector.rs

 pub struct CollectorViewOptions {
+    pub plan_id: Option<String>,
     pub views: BTreeSet<PhysicalASAPNodeId>,
 }
+impl From<&CollectorViewsFile> for CollectorViewOptions;

CLI: control plane --plan, --collector-capabilities, --emit-collector-views (--workload and --out now optional together with --plan); data plane --collector-views.

Usage

crates/data-plane/tests/collector_views.rs::the_collector_views_file_makes_the_chain_a_collector_view, run at this commit:

let capabilities = CollectorCapabilities::from_json(&std::fs::read_to_string(caps_path)?)?;
let (file, _) = collector_sub_dag(&plan, &capabilities)?;
let file: CollectorViewsFile = serde_json::from_str(&serde_json::to_string(&file)?)?; // as --collector-views reads it
assert_eq!(file.outputs, [node]);                                                      // the DDSketch chain
let options = EngineOptions { collector: CollectorViewOptions::from(&file), ..options };
// … the collector's states posted on /v1/metrics; the query answers as the view built here does,
// and `data` samples are not stored.

Open questions

  • Label-input weight. input: "label" accepts any label-item summary whatever its weight (count or per-key sum of the sample value). Today's collector's label sketches: do they weight by the sample value or count 1? Recommendation: let the collector's entry state it ("input": "label_count" / "label_value"), or require weight 1 until it does. No benchmark query has a label-input view, so it does not change any cut today.

Tests

  • control-plane/tests/collector_views.rs (rule, with today's collector's capabilities as the design prints them, tests/data/collector-capabilities.json, and synthetic variants): a leaf sketch chain is the one collector view (sub-DAG, backend_reads_raw = false, a reason for every other node); an exact view over the same metric keeps it raw; a missing sketch, an out-of-range α and a regex matcher leave the chain in the backend; a Reduce chain is local only under {"labels": L} with L among its keys; one operator line moves the cut up to the wider level; the file reads back and its views keep their installed keys; unknown capability versions, unknown fields, limits on the wrong operator, unknown limit names and an operator listed twice are refused.
  • data-plane/tests/collector_views.rs: the file written by the rule wires the collector view end to end (equal answers, raw samples not stored); a file of another plan is refused at install.
  • Gate (on chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888 b192642 before the restack onto feat(precompute): close an idle stream's last windows by wall-clock time #889; rerun on feat(precompute): close an idle stream's last windows by wall-clock time #889 below): cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace (ulimit -n 65536): 265 passed, 0 failed, 3 ignored (the previous PR plus 9 new).
  • On feat(precompute): close an idle stream's last windows by wall-clock time #889: gate 267 passed, 1 failed, 3 ignored; the failure is forward_mode::bodies_wait_for_a_raw_store_that_is_down, a known load-dependent flake of the base stack (it passes alone, 3 of 3); fmt and clippy clean. Parity dump vs feat(precompute): close an idle stream's last windows by wall-clock time #889 at this head: byte-identical (70,736 B).
  • Parity dump vs the base with no collector input: byte-identical (69,468 B), as for the previous PR.
  • Benchmarks vs the base, alternating, 3 rounds: decode_bench Remote Write 0.103–0.106 vs 0.103–0.104 µs/sample, OTLP 0.110–0.111 vs 0.111 µs/sample; ingest_bench 1000 120 views windows refreshed after 0.89 s vs 0.88–0.89 s (one slow outlier run on each tree, 4.10 s new and 1.32 s base). No regression.
  • CLI smoke run: control_plane --workload … --deployment-capabilities '{"raw_data_retained": false, …}' --out p.json --collector-capabilities caps.json --emit-collector-views cv.json wrote outputs [1], backend_reads_raw {"data": false} (and, before this restack, the grace, now removed); data_plane --plan p.json --collector-views cv.json served /v1/metrics (200); with the plan id edited it refused to start.

@zzylol zzylol added enhancement New feature or request area: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration labels Nov 28, 2026
@zzylol
zzylol force-pushed the feat/collector-views-file branch 2 times, most recently from b8a6b34 to 38b3493 Compare November 28, 2026 18:49
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 8c6f738 to 4d1070d Compare November 29, 2026 00:55
@zzylol
zzylol force-pushed the feat/collector-views-file branch from 38b3493 to 9b1bb5a Compare November 29, 2026 01:06
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 4d1070d to 6d57168 Compare November 29, 2026 18:01
@zzylol
zzylol force-pushed the feat/collector-views-file branch from 9b1bb5a to e7b33b7 Compare November 29, 2026 18:04
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 6d57168 to cd13693 Compare November 30, 2026 02:33
@zzylol
zzylol force-pushed the feat/collector-views-file branch 2 times, most recently from c49bc44 to 5eeb272 Compare November 30, 2026 03:54
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 8411b5b to 742e799 Compare November 30, 2026 06:21
@zzylol
zzylol force-pushed the feat/collector-views-file branch from 5eeb272 to f6a3f5f Compare November 30, 2026 06:21
zzylol and others added 7 commits November 30, 2026 06:43
…ta plane --collector-views

- control_plane::collector_views: the collector's capabilities (planner
  DeploymentCapabilities with collector summary entries, predicate ops,
  operator lines, placement, close delay) and the bottom-up rule (a)-(d)
  of docs/design/collector-sketch-ingest.md §1 that cuts the collector
  sub-DAG; outputs that are not views go back to the backend.
- common::CollectorViewsFile: planner wire version, plan id, commit grace,
  backend_reads_raw, outputs, sub-DAG in the planner's serde.
- control_plane --plan/--collector-capabilities/--emit-collector-views
  (+ export interval and clock skew allowance in the grace); prints why each
  other node is not on the collector.
- data_plane --collector-views: the file's outputs are the precompute
  engine's collector views; installing another plan is refused.
…builds, locality per operator, limit checks at load

- Rule (a): a reductions list limits a chain or SummaryAgg only; an
  Aggregate's grouping is left to rule (d).
- Rule (d): only operators that keep each series' rows to it are local;
  a grouping (Aggregate, chain or SummaryAgg Reduce, SummaryMerge group_by)
  is local when each group is on one instance; every other operator is
  not. The grouped input is the operator's own child.
- Capabilities: a limit on an operator it does not apply to, an unknown
  source or reduction name, or an operator listed twice is a load error.
- Scalar roots count as roots; the plan's views and the written sub-DAG
  are validated (errors propagate); --plan needs --collector-capabilities
  and conflicts with the planning flags.
- Docs: CommitGrace adds to the declared close delay; why the executor
  entry is deserialized by hand; README and common crate docs.
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…iling first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Rule (e): a node whose output holds a counter's or an instant rate's
state is never placed on the collector, whatever its capabilities
declare, so ASAPQuery-backend keeps its raw samples
(backend_reads_raw) and computes its windows again from them when late
samples come.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…close

CollectorViewOptions gained idle_close_ms (#890); the collector-views
file does not carry the collector's close delay (a new field would be
refused by readers that deny unknown fields), so the options it gives
take the default 6 s + 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths enhancement New feature or request integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant