Skip to content

mvp/v5: postings-aware GorillaQueryEngine + S3 cost tracker (issue #46) - #90

Merged
zzylol merged 1 commit into
mainfrom
mvp/v5-postings-aware-engine
May 6, 2026
Merged

zzylol merged 1 commit into
mainfrom
mvp/v5-postings-aware-engine

Conversation

@zzylol

@zzylol zzylol commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

v5 MVP — backend side. DRAFT, do not merge. Run agent will execute the demo and post numbers.

  • Postings-aware execution path in engines::gorilla_engine. Planner extracts exact-equality label matchers from PromQL; ColdStore::list_postings_for returns the matching series_ids; the ExactExecutor prunes chunks whose label_hash isn't in the set. Regex / inequality matchers fall through to a post-decode filter for correctness. New ExecutionOutcome fields (chunks_skipped_via_postings, postings_filtered_series_count, postings_missing) surface in response infos. data_source_quirk: postings_missing is emitted when the engine fell back to scan-all.
  • S3 cost tracker (drivers/query/fallback/cold_store/s3_cost_tracker.rs). Wraps the rust-s3 ObjectStore in counters; process-wide OnceLock lets the new /internal/s3_cost.csv HTTP endpoint dump the CSV the v5 demo consumes; /metrics also exposes the same counters in Prometheus exposition.

Test plan

  • cargo test gorilla_engine (24 pass — 21 originals + 3 new for postings-aware happy path / fall-back / no-predicate skip)
  • cargo test s3_cost_tracker (4 pass)
  • cargo build clean
  • (run agent) end-to-end via bash deploy/scripts/run_mvp_demo.sh in the collector repo
  • (run agent) verify /internal/s3_cost.csv returns non-zero counters for the ASAP cell

Cross-repo dependency

Pairs with mvp/v5-postings-compactor PR in ASAPCollector. The asap-query-engine/Cargo.toml carries a NOTE FOR REVIEWERS explaining the path-dep coupling — both branches must be checked out side-by-side for cargo build to resolve asap_gorilla::Postings.

🤖 Generated with Claude Code

…sue #46 v5)

Adds the two backend pieces the v5 MVP needs:

1. **Postings-aware execution path** (`asap-query-engine::engines::gorilla_engine`).
   The query planner extracts exact-equality label matchers from the
   PromQL AST (`zone="a"` etc); regex / inequality matchers are
   surfaced via `has_unsupported_matchers` and fall through to a
   post-decode filter for correctness. The `ColdStore` trait gains
   `list_postings_for(metric, range, matchers) -> PostingsHits`;
   `GorillaS3ColdStore` implements it by per-bucket fetch + LRU
   cache (256 entries) + intersect-across-matchers / union-across-
   buckets. The `ExactExecutor` calls it before the chunk-list, then
   prunes chunks whose `label_hash` isn't in the matched series
   set. `ExecutionOutcome` grows three new fields (surfaced in
   `infos`): `chunks_skipped_via_postings`,
   `postings_filtered_series_count`, `postings_missing` — the last
   of which drives a `data_source_quirk: postings_missing` line
   when the engine fell back to scan-all.

2. **S3 cost tracker** (`drivers/query/fallback/cold_store/s3_cost_tracker.rs`).
   Wraps the `rust-s3`-backed `ObjectStore` in counters for PUT /
   GET / HEAD / LIST / DELETE + bytes-out per op. A process-wide
   `OnceLock<Arc<S3CostCounters>>` lets the HTTP server's new
   `/internal/s3_cost.csv` endpoint dump the CSV the v5 demo
   script consumes; `/metrics` also appends the same counters in
   Prometheus exposition.

Backward compat: pre-mvp/v5 cold stores keep returning
`ColdStoreError::Unsupported("list_postings_for")` from the
default trait method; the executor treats that as "postings
missing" and stays correct.

Test summary:
* gorilla_engine: 24 tests pass (21 originals + 3 new for
  postings-aware happy path / fall-back / no-predicate skip).
* s3_cost_tracker: 4 tests pass.
* Full suite: 854 pass / 34 fail; the 34 failures pre-date this
  branch (verified against origin/main).

Cross-repo dependency: this PR depends on the matching
`mvp/v5-postings-compactor` PR in ASAPCollector — specifically
`asap_gorilla::Postings` and the `IndexEntry` extension fields.
`asap-query-engine/Cargo.toml` carries a NOTE FOR REVIEWERS
explaining the path-dep coupling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol marked this pull request as ready for review May 6, 2026 21:22
@zzylol
zzylol merged commit 7d46908 into main May 6, 2026
@zzylol
zzylol deleted the mvp/v5-postings-aware-engine branch May 6, 2026 21:22
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