Promql cpp functions#272
Open
cherep58 wants to merge 88 commits into
Open
Conversation
# Conflicts: # pp/go/storage/querier/querier.go
gshigin
reviewed
May 5, 2026
gshigin
reviewed
May 5, 2026
gshigin
reviewed
May 5, 2026
gshigin
reviewed
May 5, 2026
gshigin
reviewed
May 5, 2026
gshigin
reviewed
May 5, 2026
# Conflicts: # pp/go/storage/querier/merge_series_set_test.go
vporoshok
requested changes
May 7, 2026
Collaborator
vporoshok
left a comment
There was a problem hiding this comment.
Review: WindowFunctionIterator sub-interval logic vs ADR-001
Analyzed the sub-interval splitting algorithm in WindowFunctionIterator against ADR-001 (range function iteration algorithm). The code works correctly for the most common case (s < w < 2s), but has critical issues in two other cases.
Summary of findings
| # | Severity | Finding |
|---|---|---|
| 1 | Bug/Critical | advance_interval() breaks for w > 2s — produces invalid interval (min > max), potential infinite loop |
| 2 | Bug/Critical | Incorrect boundaries for w < s — aggregation captures samples from gaps between windows |
| 3 | Bug/Moderate | Possible double-count for sum_over_time at interval boundaries (depends on seek_to inclusive/exclusive semantics) |
| 4 | Design | count_over_time missing from dispatch (falls back to universal iterator — correct but no pushdown) |
| 5 | Design | sum_over_time result timestamp is last raw sample's ts, not sub-interval end |
| 6 | Observation | min/max sub-interval collapsing optimization from ADR not implemented (correct but sub-optimal) |
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
Implement C++ pushdown optimizations for PromQL functions at the storage layer. When the query engine provides
SelectHints.Func, the storage can now reduce data before it reaches the Go PromQL engine — returning only the samples needed for the specific function instead of the full series.New decorator iterators
MinOverTimeIterator,MaxOverTimeIterator,LastOverTimeIterator,SumOverTimeIterator(viaOverTimeFuncIteratortemplate with pluggable handlers)RateIterator(rate, increase),IRateIterator(irate, idelta)DeltaIterator,ChangesIterator,ResetsIteratorDownsamplingDecodeIterator— interval-based sample reductionRefactored decode iterator infrastructure
DecodeIteratorTraitwithseek(),seek_to(),invalidate(),set()methodsSeekResultenum for composable seek logic (kUpdateSample,kNext,kStop,kUpdateSampleNextAndStop)UniversalDecodeIteratorextended withseek(),seek_to(),invalidate(),set()that dispatch throughstd::visitDecodeIteratorvariant wrapping all iterator types for the Go binding layerFunction dispatch
FunctionNamesHash) for O(1) function name lookupcreate_decode_iterator()dispatches onSelectHints.Functo construct the appropriate iteratorGo bridge changes
SelectHintspassed through cppbridge via ABI-compatibleGenericSelectHints<Go::String, Go::SliceView>downsamplingMsparameter added toQuery()andChunkRecoderpathsDataStorageSerializedDataIteratorcontrol block simplified: directTimestamp()/Value()accessors replacing raw field accessentrypoint::head→entrypoint::series_dataTesting