Skip to content

rqe-optimizer: support shared multi-subpopulation sketches (HydraKLL) in the cost model #142

Closed as not planned

Description

@milindsrivastava1997

Problem

rqe-optimizer treats every capability as one sketch per group. A deployment for label set L is card(L) independent instances. Memory and ingest are priced as card(L) × per-instance cost, using LabelSetInfo.cardinality, and accuracy is one per-instance number.

HydraKLL (hydra-kll, SubpopQuantile in sketch-bench) works differently. It is one sketch that answers a quantile for every group. Its memory doesn't scale with card(L), and its accuracy depends on how many groups share it. Adding "hydra-kll" to Capability::Quantile.families() would misprice it in both directions.

What's needed

  • A way for a cost entry to say it is a shared instance: one per deployment, not card(L).
  • Memory and ingest priced from that (active_instance_count × per-instance cost, with no × card(L)).
  • Accuracy measured at the group count the RQE's label set actually has, or a curve over group count. The current single query_accuracy value is taken at whatever group count the bench spec happened to have.
  • Then add hydra-kll as a Quantile candidate. The same would let hydra-cms, hydra-hll and hydra-univmon-* in.

Related

The exact *_over_time accumulators (exact-sum, exact-max, exact-increase) are now multi-subpopulation, mirroring ASAPQuery's Multiple*Accumulator. One instance holds every group, so their measured mem_bytes_per_instance is for the whole label set at the bench spec's group count (~9.9k groups in hydra_columns.yaml). The optimizer still multiplies it by card(L). The same "shared instance" fix should apply to them.

🤖 Generated with Claude Code

Activity

  1. milindsrivastava1997 commented on Oct 5, 2026

    @milindsrivastava1997
    ContributorAuthor

    Update: the exact accumulators part under "Related" is now handled differently. atomic_costs::reduce_one divides memory and merge cost by the groups_per_instance the comparator reports. That makes their entries per-group, so the optimizer's card(group-by) × is already correct for them. This issue is now only about the Hydra sketches, whose accuracy (not just cost) depends on how many groups share one instance.

  2. milindsrivastava1997 commented on Oct 6, 2026

    @milindsrivastava1997
    ContributorAuthor

    Correction to the "Related" section above: the exact accumulators are not overpriced by card(L) today.

    aqpbm-core/src/atomic_costs.rs divides their measured mem_bytes_per_instance and merge_cpu_secs by groups_per_instance (the bench spec's group count, recorded in query_accuracy). Query cost is already per group. So the rows are per-group costs, and the optimizer's card(G) × m prices each group once, which is correct.

    What this issue still needs is unchanged for Shared + Fixed families like HydraKLL: one fixed-size instance per deployment, which is not × card(G), and accuracy that depends on group count. Per #145's scope (Q15 there), that's where the per-family "shape" property (PerGroup / Shared) belongs.

  3. zzylol commented on Oct 10, 2026

    @zzylol
    Collaborator

    Superseded by the Hydra admission design in #193 (docs/rqe_optimizer_hydra.md).

    Closing in favor of #193 (decided by @zzylol).

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions