Repository navigation
Conversation
zzylol
force-pushed
the
feat/collector-views-exact-accumulators
branch
from
November 30, 2026 16:55
19bd8d4 to
fac8f03
Compare
zzylol
changed the base branch from
feat/collector-views-late-corrections
to
feat/collector-views-lineage-frame
November 30, 2026 16:55
The planner's DeploymentCapabilities supports every exact accumulator family unless an exclusion rules it out; the collector's capabilities exclude only the counter states (counter_semantics), so they already claimed Sum/Count/Min/Max, but the collector built sketches only. - capabilities: version 2 (executor read with the planner's semantics in full); CollectorCapabilities::exclusion_of checks a node against the planner's expansion of executor. - planner_views: a leaf chain of an exact family is a view (CollectorView::summary is the planner's SummaryFamily); it must fold the sample value, have no theta and match no exclusion. - view_executor: an exact state is sent as the executor's view layout (StateColumn::view_bytes), the bytes ASAPQuery-backend stores for the state it builds of the same view; its count comes from the window's per-series sample tally. Late samples go to correction states as for sketches. - codec: a view state key without theta decodes as an Exact state. - tests/fixtures/collector-views/exact: the control plane's cut of sum/count/avg/min/max_over_time(data[1m]). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
force-pushed
the
feat/collector-views-exact-accumulators
branch
from
November 30, 2026 16:55
fac8f03 to
3acfc6a
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.
Summary
sum_over_time(data[1m]),count_over_time,avg_over_time,min_over_timeormax_over_timeon a gauge, so the backend kept readingdataraw. The collector built sketches only (DDSketch, KLL).Sum,Count,MinandMaxstates per series and tumbling window(end − w, end]on ASAPPlanner's executor. On-time samples go to the window's own state, and late samples within retention go to a correction state. Every state is a record of its lineage: a full first, then a delta for each emission of an open window and for each correction, behind the same frame as sketch states. Each state is sent as the executor's view-layout record, which is the same bytes ASAPQuery-backend stores for that view.--print-capabilitiesgoes to version 2: theexecutorblock is read with the planner's own meaning, and that meaning already covers these four exact families.sum_over_time(data[1m])givesbackend_reads_raw: {"data": false}and one collector view. Building the view costs 568 ns/sample for oneSumview, against 749 ns/sample for q01's DDSketch view (10,000 series, 10 samples/s each, one core).Review guide
feat/collector-views-lineage-frame, ff8240a, on collector_views: find a point's series by its attribute bytes (1.27 → 1.11 µs/sample) #62 on collector_views: sequence numbers and delta emission (full, then deltas per window) #61), so exact states carry the lineage frame like sketch states, and the backend deduplicates them by (epoch, sequence), not by bytes.view_executor.rs: insealandencode, the run's lineage closure and its per-series sample counts are both passed. An open window emitted mid-way (collector_views: sequence numbers and delta emission (full, then deltas per window) #61's deltas) also keeps its run's tally, so a delta'scountis that delta's samples.view_executor.rs:state_bytes,WindowRun::sample_countsandRunGroup::add. Thenplanner_views.rs:exact. Thencapabilities.rs:CollectorCapabilities::exclusion_of.CollectorView::sketch→summary. The fixturetests/fixtures/collector-views/exact/is the control plane's output (see Verification). The golden capabilities change only incapabilities_version.Behavior: before → after
Workload:
sum_over_time(data[1m]), evaluated every 5 s, on a gaugedata(10,000 series, 100 ms interval). Deployment:raw_data_retained: false.asap-collector --print-capabilitiescapabilities_version: 1, sketches onlycapabilities_version: 2, sameexecutorJSON; under the planner's meaning it supports exactSum/Count/Min/Maxand excludesCounter/IRate--emit-collector-views)collector views [], backend reads raw {"data": true}collector views [1], backend reads raw {"data": false}data.asap_view.1;sketch.envelopeholds a 24-byteSumrecord, andcountis the window's number of samplesSame result for
count_over_time,min_over_timeandmax_over_time(one view each),avg_over_time(theSumandCountviews), and the trial mixquantile_over_time(0.99, …)+sum_over_time(DDSketch +Sum,data: false).Interfaces
otap/capabilities.rsotap/planner_views.rs/// One checked collector view (type stays). pub struct CollectorView { pub identity: Arc<ViewIdentity>, pub source_metric: String, pub scan_node: PhysicalASAPNodeId, pub output_metric_name: String, - /// The chain's sketch. - pub sketch: SketchAlgorithm, + /// The chain's summary family: a sketch, or an exact accumulator. + pub summary: SummaryFamily, pub tumbling_window_width_ms: u64, pub retention_ms: u64, }Wire format (
sketch.envelopeof a view whose key has no θ,SketchType::Exact): the executor'sStateColumn::view_bytesrecord, as little-endian 8-byte words.Sum: sum, compensation, seen (24 B).Count: count (8 B).Min/Max: present, value (16 B).Usage. The control plane runs
control_plane --workload w.json --collector-capabilities caps.json --emit-collector-views cv.json, wherecaps.jsoncomes fromasap-collector --print-capabilities. Its rule accepts theExactAggregate(Sum)chain because no exclusion ofexecutormatches it, and it writescv.jsonwith that chain as an output. The collector'splanner_views::load(cv.json)reads the view assummary: Exact(Sum);exact()checks the sample-value input, that there is no θ, andexclusion_of.ViewExecutorthen runs one executor ingestion run per 5 s window. When a window closes, each series' state is encoded bystate_bytes(view layout) andencode(withcountfrom the window's tally), and sent asdata.asap_view.1.Algorithm
None new. The executor builds the states, exactly as it does for sketches. This PR only reads exact states out in the executor's view layout and counts the samples it sends per series for each window. The tally exists only in run groups that have an exact view, at one vector increment per sample.
Decisions and open questions
Needs reviewer decision
DeploymentCapabilitiescannot list an exact family.supported_summariesisVec<SupportedSummary>withsummary_type: SketchAlgorithm, and its docs say "Exact accumulators and plain exact execution are always supported". The only way to narrow them is through exclusions (counter_semantics,state_not_mergeable_across_windows,excluded_candidates). So this PR adds no field. It bumpscapabilities_versioninstead, because the JSON is unchanged but its meaning now includes exact families. Two things are not expressible in the planner's vocabulary: a positive list of the exact families an executor builds, and the input an exact accumulator reads (a sketch entry hasinput; an exact family has no entry). The control plane therefore assumes the sample value, and the collector refuses any other input.StateColumn::view_bytes) rather than an ASAPv1 encoding, since there is no ASAPv1 for exact states. ASAPQuery-backend persists exact view columns in exactly this layout (its compact form rebuilds it byte for byte).Decided (approved design): capabilities in the planner's vocabulary; asap-executor as a thin driver; Prometheus
(end − w, end]windows; states byte-equal to the backend's for the same view; no ASAPPlanner change.Verification
cargo test --features otap-engine --lib -- otap::capabilities otap::planner_views otap::view_executor otap::codecpasses all 65 tests (0 failed, 0 newly failing).cargo clippy --features otap-engine --all-targetsandcargo fmt --checkare clean. Integration suites were not run locally; the changed paths are covered by the lib tests.New tests:
capabilities::exact_accumulators_are_in_the_printed_capabilities: the printedexecutor, expanded with the planner'sexclusions(), rules out noSum/Count/Min/Maxand does rule outCounter/IRate.capabilities::exact_chains_match_no_exclusion_but_a_counters_does: the fixture's four chains match no exclusion; the same chain as aCountermatchescounter_resets_not_handled.planner_views::exact_views_load,an_excluded_exact_family_is_refusedandan_exact_chain_needs_the_sample_value_and_no_theta.view_executor::exact_views_build_per_window_states_on_prometheus_boundaries: samples at T−5 s, T−4999, T−2500, T, T+1 and T+5 s land in the windows(end − 5 s, end]. Each state equals a hand-written golden vector of the view-layout bytes (for exampleSum7.5 =0000000000001e40 0000000000000000 0100000000000000), andcountis 1, 3 and 2.view_executor::exact_states_are_the_executors_own_build: the states are byte-equal to one ingestion run per window over all of the window's samples (how the backend builds the view), for 1, 7 or 100 samples per flush, and they hold the window's sum, count, min and max.view_executor::exact_corrections_merge_into_the_on_time_state: late samples within retention become one correction per view and series (count1). The window's state merged with its correction (add, add, min, max) equals the all-on-time state.codec::exact_view_state_round_trips_through_otap_arrow: a key without θ decodes asExact, with its bytes and count.view_executor::exact_deltas_and_equal_corrections_carry_distinct_sequences: per exact view, a full (0), a delta of the open window (1), then two corrections of one late sample of value 5.0 each. The two corrections are byte-equal records (Count1,Sum5.0, …) with sequences 2 and 3, all from one epoch, and each hascount1. The backend merges both (ASAPQuery-backend#895,equal_bytes_corrections_with_distinct_sequences_both_merge).Fixture provenance:
tests/fixtures/collector-views/exact/iscontrol_plane --workload planner-workload.json --deployment-capabilities {raw_data_retained: false, query_time_results_retained: false} --emit-collector-views, from the ASAPQuery-backend control-plane draft. Output:collector views [1, 6, 12, 16], backend reads raw {"data": false}.CPU per sample, from
asap-views-bench VIEWS executor 10000 10 20 5(median of 5, one pinned core, release build):SumSum+Count(avg_over_time)Sum,Count,Min,MaxThe sketch path does not change. Groups without an exact view keep no tally.
Follow-ups
data[1m]) answered identically at 32 evaluation times × 10,000 series. The collector arm's data plane received 0 raw samples (raw arm: 2,400,000), andraw_forwarddropped all 240datamessages.Sum/Count, a partial forMin/Max. Both merge into the window, in lineage order, by the same merge as a correction.Counter/IRatestay in the backend: they are order-sensitive, andcounter_semanticsexcludes them.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf