feat: execute TopK exact values through candidate-filtered Prometheus - #558
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/topk-candidate-exact
branch
from
September 10, 2026 05:50
2af96e0 to
a44133b
Compare
zzylol
force-pushed
the
feat/topk-candidate-exact
branch
2 times, most recently
from
September 10, 2026 05:55
92bf53e to
f421aa2
Compare
zzylol
force-pushed
the
feat/topk-candidate-exact
branch
from
September 10, 2026 06:03
f421aa2 to
3c50288
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.
A hybrid
topk(2, sum by (job) (rate(...)))plan previously maintained a local exact counter subtree alongside its CMS candidate heap. That duplicated exact computation and made the warm path state cost scale with the raw series count.This change gives the installed typed DAG a candidate-dependent Prometheus leaf. The backend reads the shared CMS candidate node once, injects an anchored
jobmatcher into the exact inner PromQL through the PromQL AST, asks Prometheus only for those candidates, and then intersects/reranks the normalized exact vector. Empty candidate sets return immediately without an RPC. Candidate requests use form POSTs so larger heaps do not hit URL limits, and candidate/query size limits turn unsafe requests into the existing whole-query capability fallback.The compiler now installs only the CMS-with-heap for this hybrid branch; it does not provision an
Increase/exact-counter materialization. Existing non-hybrid plans keep their prior local exact behavior. Successful summary-candidate plus remote-exact execution reportsx-asap-execution=hybrid;exact_fallbackremains reserved for whole-query Prometheus fallback. The calibration guard distinguishes both plan shapes and fail-closes the new branch unless it records one CMS read, one candidate-filtered exact RPC/evaluation, zero local exact state, and explicit hybrid provenance.Validation:
cargo fmt -p control_plane -p data_plane -- --checkcargo test -p control_plane --lib(708 passed)cargo test -p data_plane query_engines::asap_query_engine --lib(122 passed)cargo test -p data_plane logical_provenance_tests --lib(5 passed)python3 -m unittest discover -s tools/o11y-execution -p 'test_*.py'(46 passed)