Return one terminal sample for bare instant selectors instead of unpacking every
perfloop/victoriametrics · LATE FILTERING
https://perfloop.ai/t/oss/case_9vm7m38frz
Verdict
PROPOSED · opened 2026-08-26
Hypothesis
On this spine, `evalExprInternal` wraps a bare metric selector in `default_rollup`. `timeseriesWork.do` always calls `pts.Unpack`, and `Unpack` decodes, filters, and merge-sorts every matching row before `doRollupForTimeseries` calls `rollupConfig.Do`. `rollupDefault` then returns only `values[len(values)-1]`; its accounting table also records one scanned sample per call. The other materialized rows exist only to locate that terminal value.
A dedicated terminal-sample path can use the same effective window while block headers eliminate blocks that cannot contain the final point. It must resolve equal terminal timestamps with the existing deduplication and stale-marker rules, and fall back before any overlap or boundary case is uncertain. Its expected floor is tag-filter selection, block-header traversal, the terminal blocks required for correctness, and one output point per surviving series rather than a full-window result slice and merge.
A differential test corpus covering interior timestamps, stale markers, duplicate timestamps, dedup intervals, and overlapping blocks should first prove byte-for-byte equivalence with the generic path. Then an end-to-end `/api/v1/query` benchmark over high-cardinality bare selectors at several scrape densities should compare decoded-row counts, allocations, CPU profiles, and latency. If terminal-block selection does not materially reduce decoded work or the profiles remain dominated by unavoidable boundary-block decoding, that measurement falsifies the move.
Change to test: Add a single-point implicit-`default_rollup` fast path that derives the existing effective lookback window, walks each selected packed series by block timestamp bounds, and decodes only the terminal or overlapping boundary blocks needed to resolve the final deduplicated sample. Construct the one-point series directly and retain the current `Unpack` plus generic rollup path for non-bare expressions, ambiguous overlaps, and any case that cannot preserve stale-NaN and deduplication semantics exactly.
Where it lives
perfloop/victoriametrics · app/vmselect/prometheus/prometheus.go
Evidence
No usable result yet.
Timeline
2026-08-26· Case opened