Skip to content

feat: list current-series TopK heap alternatives in PlanSpace - #477

Merged
zzylol merged 1 commit into
mainfrom
feat/physical-alternatives-in-planspace
Oct 1, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/physical-alternatives-in-planspace

Conversation

@zzylol

@zzylol zzylol commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #483.

Why

PlanSpace decides what to compute. It does not decide placement. The summary
maintenance lifecycle sets each node's timing (precompute or query), and the
physical compiler reads that timing. An instant-vector TopK has heap
realizations (CMS/CountSketch with heap) that rank rows carrying the complete
PromQL series identity. These are real logical alternatives, but PlanSpace did
not list them, so the backend built them outside Planner.

What

  • ReplacementStrategy::propose_for_root (new, default: none): whole-query
    logical alternatives for a targeted workload root. search_workload_with_targets
    asks it once per distinct root. It exists because these candidates need input
    rows (the series identity) that the logical root does not expose, so the
    per-subtree propose cannot produce them.
  • SketchAlgorithmStrategy implements it for current-series TopK only. It
    resolves identity-carrying rows with with_promql_series_identity (moved into
    asap-types so Planner can call it), then finalizes and deduplicates the
    candidates.
  • ReplacementProvenance::RootPhysicalRealization marks these candidates so that
    global_selection never commits them. Deployment validates and prices them.
  • Fixed-window and query-time Rate aggregation are placement variants, so they
    are not listed. fixed_window_rate_candidates and
    query_time_rate_aggregation_candidates stay public for the backend's
    current direct callers. Lifecycle-assigned timing replaces them in a later PR.

Before this PR

enumerate_candidate_dags_for_root for topk by(job)(1, m) lists only
logical-root candidates. To see the current-series heap, the backend applies the
series-identity pass and calls current_series_topk_candidates itself.

After this PR

The same call also lists finalized current-series heap readouts, each
bindable with promql_rows::compile_current_series_readout. The inventory for
sum by(job)(rate(m[1m])), topk by(job)(2, rate(m[1m])), rate(m[1m]) and
unrelated queries is unchanged, and so is default selection.

Validation

  • crates/asap-physical-operators/tests/planspace_series_identity_heap.rs:
    current-series heaps are listed and bindable. Rate placement variants are not
    listed (this test fails on the earlier feat: list current-series TopK heap alternatives in PlanSpace #477 head). Unrelated inventories are
    unchanged. Global selection never commits a heap. Repeated roots are proposed
    once.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings,
    cargo test --workspace --no-fail-fast. The only failure is the existing
    devtools dag_export::workload_node_ids_make_smaller_topk_reuse_explicit.

🤖 Generated with Claude Code

@zzylol zzylol changed the title feat: list PromQL physical alternatives in PlanSpace feat: list current-series TopK heap alternatives in PlanSpace Sep 30, 2026
@zzylol
zzylol force-pushed the feat/physical-alternatives-in-planspace branch from 94a6962 to 0d3b601 Compare September 30, 2026 02:07
@zzylol
zzylol changed the base branch from feat/shared-physical-operators to split/462-f-physical-planner September 30, 2026 02:07
zzylol added a commit that referenced this pull request Sep 30, 2026
#477 moved series-identity resolution into asap-types; #486 and #487 extended
the physical-layer copy. Port the extended rules into asap-types and keep
promql_rows delegating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the split/462-f-physical-planner branch from bb1abdd to 0ced125 Compare September 30, 2026 18:26
@zzylol
zzylol force-pushed the feat/physical-alternatives-in-planspace branch from 0d3b601 to c976d5c Compare September 30, 2026 18:27
zzylol added a commit that referenced this pull request Sep 30, 2026
#477 moved PromQL series-identity resolution into asap-types. The
fallback shapes compiled by #486 and #487 (time shifts, subqueries,
scalar bridges, and arithmetic between series) also need identity
realization there. Taken from integration commit 9a13ae4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Sep 30, 2026
The comparisons, set operators, and group modifiers compiled here share
series identity through asap-types (moved there by #477), while
promql_rows.rs no longer keeps its own copy. Accept every BinaryOp kind
and group modifier in `with_promql_series_identity`, excluding only
operands that read the evaluation timestamp. Taken from integration
merge a9b8fdd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol changed the base branch from split/462-f-physical-planner to refactor/physical-layer-no-panes September 30, 2026 18:27
zzylol added a commit that referenced this pull request Sep 30, 2026
The comparisons, set operators, and group modifiers compiled here share
series identity through asap-types (moved there by #477), while
promql_rows.rs no longer keeps its own copy. Accept every BinaryOp kind
and group modifier in `with_promql_series_identity`, excluding only
operands that read the evaluation timestamp. Taken from integration
merge a9b8fdd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the feat/physical-alternatives-in-planspace branch from c976d5c to 5ccaa44 Compare October 1, 2026 22:29
@zzylol
zzylol changed the base branch from refactor/physical-layer-no-panes to main October 1, 2026 22:29
@zzylol
zzylol force-pushed the feat/physical-alternatives-in-planspace branch from 5ccaa44 to 45c7fc6 Compare October 1, 2026 22:48
@zzylol
zzylol merged commit fc4a6b7 into main Oct 1, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant