Repository navigation
test(planner_fuzz): relations from the ASAPWorkloads query catalog (ratios, longer windows, rate/increase, UnivMon statistics) - #986
Merged
Conversation
Adds l-binary-over-result, m-longer-window, n-longer-window-rollup and
o-equivalent-range-function; g's outer operator follows q's own; h checks
SQL frequency statistics of a high-cardinality column, with a witness that
plans W ∪ {q'} with UnivMon as the only sketch family.
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.
Part of #879
Why
planner_fuzzchecks the reuse patterns the design docs describe. Production workloads share state in more ways than that. The ASAPWorkloads query catalog (ProjectASAP/ASAPWorkloads,docs/query-catalog.md) collects real queries: recording rules, dashboards and agent traces. Its plans pair, for example:rateandincreaseover one counter (docs: clean up L3 QueryExpr; add schema flow + L4 SketchExpr + system I/O #1–docs: QuerySpec definition + batched-queries DAG-reuse example #2);The tester had no relation for most of these. Its
h-other-statisticrelation had never reached a verdict: the KLL and KMV sketches the planner selects answer only one statistic.What
Four new relations, and changes to g and h:
q'fromql-binary-over-resultq{label="v"} / qon a labelqdoes not group by; orq / q_countfor asum_over_timeq(avg as sum/count)q's node, with the other operand planned alongsideWm-longer-windowqover the shortest longer window, up to 1 h, that is a multiple ofq'sq's pane chain lengthened; every merge of the chain inW's plan reads its old newest panesn-longer-window-rollupo-equivalent-range-functionrateandincreaseswappedq's result times, or divided by, the window in secondsg-outer-over-result(changed)q's own:topk,bottomk,max,quantile(0.5, …)or> 0h-other-statistic(changed)q's state; orW ∪ {q'}planned with UnivMon as the only sketch family, then priced with every familyThe generator now emits more of these shapes:
src_ipwith one value per series. Its frequency statistics useCOUNT(DISTINCT src_ip)and the L2 and entropy SQL idioms of planner-layering Example 2.rateforincrease, pick another frequency statistic ofsrc_ip, or take a 30-minute or 1-hour window.The README's coverage table cites each new pattern by its catalog number. No planner behavior changes.
How
relations.rs:derive.coarser: c's derivation, factored out so n can reuse it.witness_roots: three witnesses need it because they changeW's own roots, not only add a root forq'.longer_chain_rootslengthens the chain and rewrites every reader of it.GraftWithOperandplansWwith the sibling operand added.UnivMonOnlyplansW ∪ {q'}with UnivMon as the only family.mod.rs:FuzzWorkload::sketch_familiesfilters the deployment's supported summary families.generate.rs: the SQL frequency aggregates, thesrc_ipcolumn, and the new related-query edits.Key code interfaces added / modified
crates/devtools/src/planner_fuzz/relations.rscrates/devtools/src/planner_fuzz/mod.rscrates/devtools/src/planner_fuzz/generate.rsUsage (a real run; the draft is s61-001):
Major algorithm changes
None in the planner. The fuzz tester's witness construction now has two forms:
Adds a root. The original form:
W's selected plan plus one root forq'.Rewrites
W's plan as well. Still a plan forW ∪ {q'}, soderive_cost = cost(witness) − cost(W's plan)keeps its meaning. Three witnesses use it:W's readers of the lengthened chain merge only their old newest panes.Wis replanned with the sibling operand added.UnivMonOnlyreplansW ∪ {q'}with one family.A violation found through the h witness means one of two things: a rule never generates the shared UnivMon, or the full search misses a plan that the restricted search finds.
Before this PR
ratewithincrease, a ratio over a shared operand, or windows longer than 10 minutes over one metric.hnever reached a verdict: 2,926 inconclusive checks in the one-hour run.After this PR
Two smoke runs on main a9737a7: 20 seeds × 10 minutes each, default search, accuracy guarantees enforced.
The drafts point to three missed-reuse patterns. They are not filed yet; they will be reviewed after the one-hour rerun.
rateandincreaseof one counter never share state, exact or approximate. Seed 43:rate(m_counter[1m])plusincrease(m_counter[1m]). The marginal cost is 0.000233/s against a witness's 0.000033/s.q's chain.topk(3, sum by (instance)(m_gauge))recomputes an exact instant sum.quantile(…) > 0over an approximate quantile does not read it either.Limits:
qthat is planned with a pane chain. Approximate sketches are rebuilt over the whole window on each evaluation, so n had no conclusive checks in these runs.qmerges more than one pane chain whole, such as an SQL idiom's exact row-count guard.Verification
cargo test -p asap-devtools --lib planner_fuzz: 10 passed. New:workload_catalog_relations_derive. Updated: h instatistic_and_selection_relations_derive.cargo test --release -p asap-devtools --test planner_fuzz: 16 passed. Seven new tests require a verdict from each new witness:GraftWithOperand, because the plain graft cannot price.cargo clippy -p asap-devtools --all-targets -- -D warningsandcargo fmt --check: clean.increaseequalsrate × windowon both executor paths.UnivMonOnlyis a valid plan forW ∪ {q'}.qmerges several chains, l's avg form is limited to no outer operator orsum, and the h swap comment and stale docs were fixed.🤖 Generated with Claude Code