Repository navigation
Collector views of exact accumulators: control-plane placement and data-plane ingest (sum/count/avg/min/max_over_time) - #895
Draft
zzylol wants to merge 2 commits into
Conversation
The planner's DeploymentCapabilities lists no exact family: each is supported unless an exclusion its fields expand into rules it out. The collector rule read sketches only, so `sum_over_time(data[1m])` (an exact Sum chain) stayed in the backend and `data` was read raw although the collector's capabilities exclude only the counter states. Rule (a) now accepts an exact accumulator build over the sample value when no exclusion of `executor` matches the node. The capabilities version goes to 2: the same JSON now means exact families are built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
force-pushed
the
feat/collector-exact-accumulators
branch
from
November 30, 2026 16:54
863a6cf to
99932b0
Compare
zzylol
changed the base branch from
feat/collector-views-file
to
feat/collector-lineage-reorder-frame
November 30, 2026 16:55
A collector sends an exact accumulator's state as the executor's view layout of it (StateColumn::view_bytes), the record this data plane stores the state as, behind the lineage frame; there is no ASAPv1 encoding of an exact state, so CollectorViews::new refused every exact view. The view's decoder is now a StateDecoder: ASAPv1 for a sketch, and for Sum/Count/Min/Max the one record read back with StateColumn::from_views (a record of another size or a bad presence word is a decode reject). Counter and IRate views are refused (their states depend on sample order). Lineages, the reorder buffer, merging, commit on arrival and late merges are unchanged: they hold the decoded kernel state. Two corrections with equal bytes are distinct records of their lineage and both merge (collector_exact_views tests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
force-pushed
the
feat/collector-exact-accumulators
branch
from
November 30, 2026 16:55
99932b0 to
3ff92a0
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,count_over_time,avg_over_time,min_over_timeandmax_over_timeon a gauge never used the collector. The control plane's collector rule accepted sketch chains only. And even with a collector view placed, the data plane refused to start, becauseCollectorViews::newwanted an ASAPv1 decoder and exact states have none.executorexpands into (the planner's ownDeploymentCapabilities::exclusions) matches it.capabilities_versiongoes to 2.Sum/Count/Min/Maxcollector view decodes its state, behind the collector's lineage frame, as the executor's view-layout record (StateColumn::from_views), the bytes this data plane already stores exact states as. Lineages (Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893) deduplicate and order the records exactly as they do for sketches.backend_reads_rawis{"data": false}. In an end-to-end run, with 10,000 series fed through collector feat(sketch-core,ingest): delta decode for CountSketch + CountMin #63, answers were identical to a raw-ingest data plane for all 5 queries at 32 evaluation times, and the collector-arm data plane received 0 raw samples (raw arm: 2,400,000).Review guide
feat/collector-lineage-reorder-frame, 60127a2, on Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893), so exact views run only with lineage deduplication.14473416, data plane3ff92a05.collector.rs: I kept the lineage version ofArrivedStateandStaged(no byte hash) and putStateDecoderin front of it.control-plane/src/collector_views.rs(within_summaries,within_exact), thenprecompute/src/collector.rs(StateDecoder, the decoder choice inCollectorViews::new). Both are small.SupportedSummary.summary_typeis aSketchAlgorithm), so the rule reads the planner's exclusions instead. That is about 50 lines, with no new vocabulary.collector_exact_views.rs). They send states behind the lineage frame, withasap.producer_epoch, as the sketch tests do. No series-key code is touched.capabilities_version: 2.Behavior: before → after
control_plane --workload <query every 5 s on a gauge> --deployment-capabilities {raw_data_retained: false} --collector-capabilities <asap-collector --print-capabilities> --emit-collector-views cv.json:sum_over_time(data[1m])[],data: true[1](exactSumchain),data: falsecount_over_time/min_over_time/max_over_time[],true[1],falseavg_over_time[],true[1, 5](Sum,Count),false[],true[1, 6, 12, 16],falsequantile_over_time(0.99, …)+sum_over_time[1],true[1, 6],falsedata_plane --plan plan.json --collector-views cv.jsonon an exact view: before, it exits at start-up withcollector view 1: its state has no ASAPv1 encoding; after, it ingests the states and commits their windows.Interfaces
control-plane/src/collector_views.rsprecompute/src/collector.rs(crate-private)Wire format. On a view whose key has no θ,
sketch.envelopeholds the lineage frame followed by one record as little-endian 8-byte words:Sum: sum, compensation, seen (24 B)Count: count (8 B)Min/Max: present, value (16 B)A record of another size, or a presence word that is not 0 or 1, is rejected as
decode. ACounter/IRatecollector view is refused at start-up, because its state depends on sample order.Usage. Control plane as in the table. The collector (#63) sends each series' state per 5 s window to
/v1/metrics: a full first, then a delta for each emission of an open window and for each correction.CollectorViews::checkunframes the lineage and decodes the record into anExactAccumulator.Staging::stageapplies it to its (epoch, series, window) lineage, merging withmerge_with(add / add / min / max); a record already applied is a duplicate, and one that arrives early waits in the reorder buffer. The window commits when its request ends, and later records merge into it through the late path. A query reads the view's rows, exactly as it would rows the data plane built itself.Algorithm
None. The control plane gets one more check in rule (a). The data plane decodes one more kind of bytes; lineages, the reorder buffer, merging and committing are unchanged, because they hold the decoded kernel state.
Decisions and open questions
Needs reviewer decision
Decided
Count1). A pre-restack version of the partials test failed on exactly this:late_mergedwas 0 where 1 was expected. On Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893's lineages, a record is a duplicate only when its (epoch, sequence) was already applied.equal_bytes_corrections_with_distinct_sequences_both_mergechecks this case.Verification
cargo test -p control_plane --test collector_viewscargo test -p precompute --lib -- collector::testsits state has no ASAPv1 encodingcargo test -p data_plane --test collector_exact_views(new)cargo test -p data_plane --test collector_views(sketch views, #893/#897)cargo clippy -p control_plane -p precompute -p data_plane --tests,cargo fmtNew tests:
a_leaf_exact_chain_is_the_collector_view,exact_and_sketch_views_of_one_metric_all_go_to_the_collector,an_excluded_exact_family_stays_in_the_backend(control plane).an_exact_collector_view_decodes_its_view_layout_records: aSumrecord decodes, two merge to 10.0, and the window's row holds that same record. A 16-byte or 3-byte record is no state.exact_collector_states_answer_as_the_views_built_here: all four views' framed states answer all five queries exactly as a data plane building from the same samples.data's raw samples are not stored.exact_partials_and_corrections_merge_and_repeats_are_duplicates: per view, the fulls of two collector instances merge and a repeat is a duplicate. A correction (a delta, sequence 1) after the commit islate_mergedand its repeat is a duplicate. The answers then equal the on-time build.equal_bytes_corrections_with_distinct_sequences_both_merge: two corrections with identical bytes (Count1,Sum42.5, …), sent as sequences 1 and 2, both merge (late_merged2,duplicate0), andcount_over_timeandsum_over_timeinclude both late samples.bytes_that_are_not_the_views_record_are_rejected.End to end (local, release builds of #63 at 3acfc6a and this PR at 3ff92a0). Two arms were fed the same samples by the seeded paced feeder: 10,000 series at 1 sample/s for 240 s.
collector_views+raw_forward) → data plane with--collector-views.data[1m]; the control plane cut it into collector views[1, 6, 12, 16]withdata: false.asap_samples_total{accepted})asap_raw_data_bytesraw_forwardmessages dropped (dataread only by views)asap_view_bytesat the endView memory, A vs B. The gap is identical in two runs (+12.48 MB, +32 %), and both arms hold the same windows. It is not a correctness issue. I measured it by charging one window per exact view both ways (
ViewStore::bytes, 50 series). A collector-built window costs more per row becausewith_view_layout_stateskeeps it in the view layout throughStateColumn::from_views:u32offsets, whichfrom_viewscharges although a record column drops them.Min/Maxonly: a further +6.7 B, because the view record is 16 B (presence word, value) where the sealed column holds 9 B.Per series-window across the four views that is +29.8 B, about 7 MB of the 12.5 MB at this plan's retention (60 s plus the 60 s margin). The rest is not yet explained. The backend cannot fix this alone: the executor has no public constructor that seals decoded exact states into its compact record column (
StateColumn::sealedandfrom_exactarepub(crate)), andfrom_viewscharges the offsets inside ASAPPlanner. So it is not fixed here.Follow-ups
Sum/Countincrement or aMin/Maxpartial for each emission of an open window, and lineages apply them in order. No exact-specific change is needed.from_viewsthat does not charge offsets for record layouts. Both are ASAPPlanner changes. The unexplained remainder needs a per-view byte breakdown.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf