Repository navigation
Conversation
Pass 2 keeps the least listed precision that meets the reader's target, so a
full 12..=18 list avoids paying up to 2x state for the gaps of {13,15,17,18}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- MeasuredSketchAccuracy::from_json: the loader (parse + validate). - HLL's guarantee comes from a measured per-value table instead of the removed level-linear-counting certificate: the certificate tests are dropped (the classic small-range contract stays) and the properties test keeps its HLL filter. - A readout with no theoretical guarantee (UnivMon's distinct count and entropy) reads in its statistic's metric (relative, absolute bits), so a measured entry supplies its guarantee; without one it is still pruned. - crates/accuracy/measured/hll_distinct.json: HLL's measured relative error per value at precisions 12..=18 (ASAPBench study_saturation.py --phase hll-tail), with tests: the table loads, p14 meets rel 0.05 at delta 0.05 per value, HLL has no guarantee without a table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Production planning (the asap_planner CLI and any PlanningModels caller, the SIL intent path included) can read a measured accuracy table; without one, nothing changes (PlanningModels::builtin has no evidence). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hll_distinct_ingest: W1, W2 and the MILP fixture state per-value targets and plan with the committed HLL table (W1's p* follows the table); KMV's unchanged check and the ranked query keep whole-result targets; new: HLL pruned without a table. univmon_measured_accuracy: UnivMon's entropy kept with an entry within 0.1 bits at delta 0.05, pruned without one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…table --measured-accuracy - hll_distinct.json now measures the executor's HyperLogLogSparse (asap_sketchlib d28d5a6): 2,000 trials per point, counts 1..1e6, 1-360 merged panes; worst rel error at delta 0.05: p12 0.0477 ... p18 0.0126. - univmon.json: UnivMon's distinct count (relative) and entropy (absolute bits) for the 16 listed shapes up to 64 MB a state, counts 1..1e5. - --measured-accuracy is repeatable; the files' entries are joined. - Tests: the UnivMon table loads and gives entropy a guarantee; Pass 2 keeps UnivMon's entropy with the committed table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With HLL's measured table the fixture's p* is 12, not the certificate's 17, so the chain is cheaper than planned: on the stack with the sparse HLL pricing (#1556) it wins by 3.8x every 10 s (a 7,093, b 462, c 123) and still wins hourly (2.36 vs 26.9 / 8.5). The margin becomes 2x, and the hourly test checks the oracle itself: the MILP picks the cheapest of (a), (b), (c) and keeps the chain exactly when (c) is cheapest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASAPBench#295 now measures the counts near 2.4 * 2^p where HLL's estimator switches from linear counting to the harmonic mean; the 10-per-decade grid had stepped over that spike. New worst rel error at delta 0.05 per value: p12 0.0507 (misses 0.05), p13 0.0426, ... p18 0.0297 (1,000 trials at the band points). W1's p* becomes 13; a test pins that p12 misses and p13..18 meet rel 0.05. The 10 s MILP test's margin is 1.5x, so it holds with dense pricing (this branch alone) and with the sparse pricing of #1556. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
HLL's distinct count, and UnivMon's distinct count and entropy, have no guarantee with a known failure probability, so Pass 2 prunes them under any accuracy target. The certified HLL route was replaced (user decision, 2026-12-03) by measured per-value accuracy: tables measured on the executor's own states (ProjectASAP/ASAPBench#295), loaded with a validating loader and passed to production planning with
asap_planner --measured-accuracy/PlanningModels::with_evidence. Example: W1 (count(DISTINCT value)per host over 1 h, rel 0.05 at δ 0.05 per value, 10,000 hosts). Before: all HLL θ pruned and the plan scans raw data. After: Pass 2 keeps HLL p13 (measured worst 0.0426; p12 misses at 0.0507) and its 10 s → 900 s pane chain.Review guide
feat/hll-ingest-exec(track 1: the sparse HLL state, sketchlib pin d28d5a6). Track 3's feat(cost,accuracy): price HLL states by their distinct items; a ranking (Limit) keeps its input's error #1556 (cost + ranking) is stacked on the same base. This PR is track 2 of 3.crates/accuracy/src/measured.rs(from_json),crates/accuracy/src/readout/mod.rs(measured_only_metric),crates/planner/src/models.rs, the--measured-accuracyarm incrates/planner-cli/src/bin/asap_planner.rs.crates/accuracy/measured/hll_distinct.json,univmon.json(generated by ASAPBench#295; not hand-edited).parameter_lists(HLL 12..=18); integration fixtures switched toaccuracy_scope: per_value.Behavior: before → after
asap_planner --workload w1.json --sql-catalog-table '<flows>' --run-until stage1_pass2 \ --measured-accuracy crates/accuracy/measured/hll_distinct.jsonwith
"requirements": {"accuracy": {"max_error": 0.05, "failure_probability": 0.05, "accuracy_scope": "per_value"}}.SummaryAgg HLL(Pass 2)Hll(precision=13)(p12 below the required accuracy, p14..18 above the reader threshold)SummaryEstimate "Cardinality"entropy_over_time, abs 0.1 bits δ 0.05 per valueInterfaces
crates/accuracy/src/measured.rsimpl MeasuredSketchAccuracy { + /// The table in `json` (this type's serde form, e.g. a calibration's output file), validated: + /// the loader to call before handing a table to the planner. Err names the parse or check failure. + pub fn from_json(json: &str) -> Result<Self, String>; pub fn validate(&self) -> Result<(), MeasuredSketchAccuracyError>; }crates/planner/src/models.rs,crates/planner/src/lib.rsimpl<'a> PlanningModels<'a> { + /// These models with the deployment's measured accuracy (e.g. a loaded MeasuredSketchAccuracy). + pub fn with_evidence(self, evidence: &'a dyn AccuracyEvidence) -> Self; } +/// Re-exported so callers (CLI, SIL intent callers) can load a table without depending on asap-accuracy. +pub use asap_accuracy::MeasuredSketchAccuracy;crates/accuracy/src/readout/mod.rs(crate-private; the behaviour change)crates/types/src/summary_type/parameter_lists/mod.rsCLI (
asap_planner.rs) and file format:Usage (end to end, checked by
measured_accuracy_flag_lets_pass2_keep_hllandhll_distinct_ingest::pass2_keeps_least_measured_hll):The SIL intent path is the same:
plan_intents(…, models.with_evidence(&table), …).Algorithm changes
Where a readout's guarantee comes from (Pass 2). Problem: UnivMon entropy / distinct had no readout metric, so a measured entry could never match (
measured_guaranteeneeds the metric). Before: metric = first listed θ's theoretical guarantee's metric, else None, so the readout gets NoGuarantee. After: the same, falling back to the statistic's metric (measured_only_metric). Correctness: without a measured entry,evaluableis still false, so the readout is still pruned (univmon_entropy_pruned_without_a_meeting_entry,hll_has_no_guarantee_without_a_table). A target in another metric is pruned by the metric rule instead of NoGuarantee. Complexity: unchanged. Measurement method and limits: ASAPBench#295.Review fix (2026-12-04)
The first table (c504f14 / f60c217) came from a 10-per-decade count grid that stepped over HLL's linear-counting → harmonic-mean switch band near 2.4·2^p. It understated the worst error up to 2× (p16 0.0150 → 0.0319) and passed p12. The table now includes the band (ASAPBench#295 87f3ce2): p12 0.0507 misses, so p = 13*.
Decisions and open questions
accuracy_scope: per_value, δ 0.05 per value; the paper calls it a measured per-value bound. UnivMon added to scope.ORDER BY c DESC LIMIT 10, whole-result target, part D splits δ over 10,000 hosts → 5e-6 per host) cannot be served by measurement: the table records δ ≥ 3/trials = 0.0015. However,HyperLogLogSparseis exact (δ = 0) while a group's union holds ≤ m/8 items (p16: 8,192; p17: 16,384; p18: 32,768), and merged panes stay exact while the union stays ≤ m/8. E6 drill x1: flows 20,000 rows/s over 10,000 hosts gives 7,200 rows per host per hour on average, so ≤ 7,200 distinct per host-hour < 8,192 (p16). q2 / lightcone: auth 10,000 rows/s over 100,000 (host, user) series is about 60 rows per series per 10 min, so a user over 10 hosts has ≤ 600 < 1,024 (p13). So the drill is exact at p16 (q1) and p13 (q2) if the facts bound the per-group distinct count. The planner cannot express that today:max_distinct_per_evaluationis per source (100,000 in E6), and rows/s ÷ groups is an average, not a bound. Needed: a per-group bound fact, e.g.max_distinct_per_group_per_evaluation(or max rows per group per window), whichguarantee/hllturns into "exact" when ≤ m/8. Recommendation: add that fact (small PR), or run the drill q1 with per_value scope. Not implemented here.Verification
asap-accuracy(all)asap-types(all)asap-stage1-pass1-…asap-planner-cli --test planner_cli(incl. sketch snapshots)univmon_measured_accuracyhll_distinct_ingest(this branch alone)ranked_distinct_keeps_estimates: needs δ 5e-6 (see above); MILP tests passhll_distinct_ingest, stacked with #1556 (local merge, c42b43a)ranked_distinct_keeps_estimatesonlyhll_measured_accuracythe_switch_band_makes_p13_the_least_precision_for_five_percentFollow-ups (deferred)
HydraUnivMon(and the other Hydra algorithms) have an empty parameter list, so there is nothing to measure.REQUIREclause cannot stateaccuracy_scopeyet, so the drill intent uses whole-result targets.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi