Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions aqpbm-core/src/atomic_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,5 +765,15 @@ mod tests {
json,
r#"{"sketch":"cms","sketch_config":{"algorithm":"cms","params":{"cols":1024,"rows":3}},"mem_bytes_per_instance":12288.0,"insert_cpu_secs":5e-7,"merge_cpu_secs":0.01,"query_cpu_secs":4e-6,"query_accuracy":{"relative_error_mean":0.01},"accuracy_metric":"relative_error_mean","measured_at":{"items_per_instance":1000000,"keys_per_instance":10000,"value_range":null,"merge_operand_items":null,"distribution":null}}"#
);
// A Hydra row also names its dataset and schema width; other rows
// leave both out, and rows written before them still load.
let hydra = MeasuredAt {
dataset: Some("hydra_http".into()),
schema_width: Some(4),
..entry.measured_at.clone()
};
let json = serde_json::to_string(&hydra).unwrap();
assert!(json.ends_with(r#""distribution":null,"dataset":"hydra_http","schema_width":4}"#));
assert_eq!(serde_json::from_str::<MeasuredAt>(&json).unwrap(), hydra);
}
}
16 changes: 12 additions & 4 deletions docs/rqe_optimizer_candidates.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,18 @@ univmon-cardinality, KLL and DDSketch. These don't, and serve only
only bare `rate`/`increase`, which keep every label.)
- **Top-k** (CMS-heap, CountSketch-heap, univmon-topk). A coarse group's top
`k` can hold keys that are in none of its fine groups' heaps.
- **Hydra**. It inserts every label subset of its schema, so a coarse
grouping inside the schema is answered directly from the grid, never by
merging fine groups; it is not a candidate today
([Hydra](rqe_optimizer_hydra.md)).
- **Hydra** (hydra-hll, hydra-univmon-cardinality, hydra-kll; planned only
with undeployable families allowed). It inserts every label subset of its
schema `Λ`, so any non-empty `G_r ⊆ Λ` is answered directly from the grid,
never by merging fine groups. A metric with a Hydra dataset
(`MetricFacts::hydra_dataset`) gets one grid per (capability, filter,
window, slide, config), over its full schema only (every schema label,
not the per-series ones), because that is the width the study measures
cost and accuracy at; its cost rows must name that dataset
(`measured_at.dataset`). Its accuracy is held to the worst case: the max
error over the covered groups, worst over the measured N and seeds
(`hydra_saturation.csv`), while per-group sketches read seed-mean curves.
The design is in [Hydra](rqe_optimizer_hydra.md).

- **Cost**: ingest, compaction and storage stay at `G_d`; the query job merges
`I_d · n − I_r` times and answers `card(G_r)` groups
Expand Down
23 changes: 12 additions & 11 deletions docs/rqe_optimizer_cost_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ is in [Hydra](rqe_optimizer_hydra.md).
query memory is summed as if concurrent, there is no worker fan-out or
compaction, and latency is serial query work. It is not the evaluation's
billing model.
- **Hydra** is future work, not a candidate today; see
[Hydra](rqe_optimizer_hydra.md).
- **Hydra** is a Shared + Fixed sketch (below), a candidate only with
undeployable families allowed, built over a metric's full schema
([Candidates](rqe_optimizer_candidates.md), roll-ups section).

The two implemented objectives share the same resource primitives and §3's
table; they differ in how they account for them over time, and in latency
Expand Down Expand Up @@ -375,14 +376,13 @@ The model uses `I_d × m`, where `I_d` is instances per window:
(`groups_per_instance`), making `m` a per-group cost. Their query cost is
already per group.
- Shared + Fixed: `I_d = 1`. In code this is the family property
`one_fixed_size_sketch_for_all_groups`, true only for HydraKLL. It applies
`one_fixed_size_sketch_for_all_groups`, true only for the Hydra families. It applies
to memory and merge; query stays `card(G_r) × c_qry`, one probe per answered group.
Today's code also requires `card(G_d)` to be at most the `subpopulations`
its row was measured at. That is necessary, not sufficient: a Hydra
group's error depends on the grid's fanned-out mass against the group's
own size, not on the group count alone, so admission needs the measured
predicate of [Hydra](rqe_optimizer_hydra.md) §2.4. HydraKLL is never a
candidate today, so the check decides nothing.
A fixed-size sketch degrades as groups grow, so Hydra is built only at the
full schema its rows and accuracy were measured at (`measured_at.dataset`,
`hydra_saturation.csv`), and its accuracy is the worst case: max over the
covered groups, worst over N and seeds (per-group sketches read seed-mean
curves).

PerGroup + PerKey is deferred until a family needs it: it needs the key labels
`K`, the metric's labels minus `G`. So for every family in use, nothing scales
Expand All @@ -404,8 +404,9 @@ follows from it):
A Hydra grid is the Shared + Fixed case, `I_d = I_r = 1`; its row, probes
and key tracker are in [Hydra](rqe_optimizer_hydra.md) §3.

HydraKLL has `FamilyProperties` but is in no capability's family list, so it
is never a candidate; see [Hydra](rqe_optimizer_hydra.md).
The Hydra families are in their capabilities' family lists but not in
`DEPLOYABLE_FAMILIES`, so they are candidates only when undeployable families
are allowed (the §6.3 eval runner); AutoSketch skips them (#159).

### Family properties and key tracker

Expand Down
8 changes: 5 additions & 3 deletions docs/rqe_optimizer_hydra.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# RQE optimizer: admitting Hydra

Status: design, not implemented. Hydra is never a candidate today:
`hydra-kll` has `FamilyProperties` (`rqe-optimizer/src/lib.rs`) but is in no
capability's family list, and the other four Hydra variants have none. This
Status: hydra-hll, hydra-univmon-cardinality and hydra-kll are candidates
when undeployable families are allowed (the §6.3 eval runner), built over a
metric's full schema with accuracy from `hydra_saturation.csv`
([Candidates](rqe_optimizer_candidates.md), roll-ups section). They are not
in `DEPLOYABLE_FAMILIES`, so ASAPQuery's planner never sees them. This
document says, for each Hydra combination sketch-bench benchmarks, what
accuracy guarantee it has, how it is costed, how it would enter the
candidates and the MILP, and what sketch-bench must measure first. Symbols
Expand Down
1 change: 1 addition & 0 deletions rqe-optimizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ description = "v1 brute-force solver for the RQE -> sketch-deployment mapping pr
aqpbm-core = { workspace = true, default-features = false }
serde_json.workspace = true
good_lp.workspace = true
csv.workspace = true
Loading
Loading