Repository navigation
Conversation
…s compute it once (failing first) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…ly views A query-time OneEvaluation result was kept only at a time at or before the raw-data watermark. A node reading only views (a merge of collector view windows; with no raw data there is no watermark at all) was then computed again by every query run that read it. Its run succeeding means every window it read was stored, and a stored window changes only by a revision, which the entry's revision check already catches: the same rule the result cache applies to a root's final answer. Retention counts back from the watermark or the newest time kept, never from a client's time no stored window reaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
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
OneEvaluationresult (for example, the 1-minuteSummaryMergethat several quantile queries share) was kept only at evaluation times at or before the raw-data watermark. A data plane whose views all come from a collector has no raw data, so it has no watermark. Every query run then recomputed the shared merge.Review guide
feat/collector-views-file(Collector views: control plane rule and collector-views file, data plane --collector-views #891). The bug appears once collector views are deployable. This PR touches neither the lineage code (Collector view states: sequence numbers and deltas, incomplete windows, idle close from the declared delay #893) nor the series-key code.QueryTimeResults::get_or_computeincrates/storage/src/store.rs: the keep rule and the retention horizon. ThenCompiledQueries::newandoutputincrates/query/src/lib.rs:reads_raw_datanow also covers shared nodes.query_time_results_*tests gain the newtrue(reads raw data) argument.Behavior: before → after
The workload has four
quantile_over_time(q, data[1m])/max(...)queries at a 5% target, every 5 s. The plan shares oneSummaryMerge(the 1-minute merge of 5 s DDSketch windows) and oneProject. In the collector arm, the views come from collector states and no raw samples are stored.query-*thread CPUThe raw-ingest arm already shared most results through its watermark: 0.194 → 0.193 cores. Now it also keeps results at times the watermark has not yet reached.
Interfaces
crates/storage/src/store.rsimpl<E: Clone> QueryTimeResults<E> { /// `node`'s output at `time_ms`, as of `views`: stored, or computed now /// by `compute` (once, however many runs ask at once, when `node` reads /// only views, `reads_raw_data` false, or `time_ms` is at or before /// `watermark_ms`; by each run otherwise). pub fn get_or_compute( &self, node: PhysicalASAPNodeId, time_ms: i64, watermark_ms: Option<i64>, + reads_raw_data: bool, views: &ViewStore, compute: impl FnOnce() -> Result<Vec<Batch>, E>, ) -> Result<Arc<Vec<Batch>>, E>; }Usage: an instant query
quantile_over_time(0.5, data[1m])atTreachesCompiledQueries::outputfor the sharedSummaryMergenode. That call is nowresults.get_or_compute(merge, T, snapshot.watermark_ms /* None: no raw data */, false /* reads only views */, &snapshot.views, run). The first query atTcomputes the merge, and the other three read it. This is checked byqueries_sharing_a_merge_of_collector_windows_compute_it_once(1 compute, 1 hit) and on the live demo (2 computes, 3 hits per tick).Algorithm changes
Keep rule of the query-time partition.
time_ms <= watermark.Scanreached without passing a view) keeps step 1.ViewStore::read). So a kept result read only stored windows. A window changes only throughmerge_late,replace_windowormark_incomplete, which all callrevised.changed_sincethen makes the entry stale. This is the same reasoningCompiledQueries::evaluatealready applies to the result cache's final answers.max_bytes). Before, it held none.Decisions and open questions
None.
Verification
data_plane --test collector_viewsqueries_sharing_a_merge_of_collector_windows_compute_it_once, failing first with (computes, hits) = (2, 0)data_plane --test shared_resultsdata_planesuitesrange_isolation,no_forward,push_precompute,planner_executor_answers,server,query_protocols,result_cache,range_queriesstorage --lib query_time_resultsquery_time_results_of_a_node_reading_only_views_need_no_watermark(kept without a watermark; a failed far-future run keeps nothing and evicts nothing; retention from the newest time kept)query(all)cargo fmt --check;cargo clippy -p storage -p query -p data_plane --all-targets -D warningsLive demo (10-minute steady state each, same host, same feed, measured from per-process CPU and RSS; binary = #893 + #894 + this PR + the collector label-columns fix):
A perf profile before the fix (30 s at 499 Hz) showed 78% of A's samples on the
query-*threads, against 39% for B.Follow-ups
<Vec<u8> as Debug>::fmt, instantiated in ASAPPlanner'sasap_executor. The likely caller isgroup_seed(operators/summary), which hashesformat!("{:?}", label)for each group. It is the only{:?}formatting on the operators' per-group path. Hashing the key bytes directly would avoid it, but that code belongs to the ASAPPlanner repository.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf