Repository navigation
chore(deps): bump asap_sketchlib to main a05b35c (+ #267, #270, #271 views); plan wire version 16 - #1539
Merged
Conversation
…views) Pins planner-pin/main-a05b35c-shrink-to-fit (01f3333): sketchlib main a05b35c with the open KLL and DDSketch shrink_to_fit PRs (#267, #270) and #271's zero-copy views ported to main's DDSketch (no sum/min/max). - SketchAlgorithm variants take sketchlib's full names (KLL, HLL, KMV, CountMinSketch, HydraCountMinSketch, ...) across crates, fixtures, snapshots, docs and the DAG viewer; the planner's own SketchParams names (Kll { k }, ...) stay. - The plan file writes those names, so INSTALLABLE_PLAN_WIRE_VERSION 15 -> 16. - estimated_memory_bytes -> theoretical_memory_bytes. - DDSketch's view header shrank 88 -> 64 B: the stored-state price follows (new test pins it to the library's view bytes), and the value-shape bands are recalibrated. Sketch plan snapshots: same plans, DDSketch plans cost 0.09-1.28% less. - DDSketch q = 0 / q = 1 read bucket representatives (within alpha), no longer the exact min / max; the executor test checks within alpha.
zzylol
force-pushed
the
chore/bump-sketchlib-latest
branch
from
November 27, 2026 20:30
33b2b6d to
9b7bab4
Compare
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
asap_sketchlibat 389530c, a commit on the asap-aware-mapping: whole-plan (cross-group) cost-based selection over the search's candidate-plan space #271 views branch from before sketchlib main's breaking changes (asap-aware-mapping: Cascades/Volcano-style candidate-plan search engine over ReplacementStrategy #252–feat(asap-aware-mapping): add workload-aware fine-to-coarse rollups #262). Every other repo is moving to sketchlib main.shrink_to_fit, feat(frontend-sql): model SQL window frame clauses (ROWS/RANGE BETWEEN ...) #270 DDSketchshrink_to_fit, asap-aware-mapping: whole-plan (cross-group) cost-based selection over the search's candidate-plan space #271 zero-copy views). They are merged onto that main on the pin branchplanner-pin/main-a05b35c-shrink-to-fitat 01f3333. Then adapt the planner: the newSketchAlgorithmnames,theoretical_memory_bytes, and the smaller DDSketch state.quantile-single-mvpgoes from 8.008e-7 to 7.906e-7 $/s, and its 10 s DDSketch windows keep 109.0 MB instead of 116.5 MB. The plan file's sketch names change ({"Sketch":"Kll"}→{"Sketch":"KLL"}), soINSTALLABLE_PLAN_WIRE_VERSIONgoes from 15 to 16.Review guide
Base:
mainat a51c623 (after #1535, #1537 and #1536). This PR is not stacked.Read these first:
Cargo.toml: the pin and its comment. The pin commit is listed under Decisions.crates/cost/src/node/state_bytes/{mod.rs,tests.rs}: the DDSketch view header drops from 88 to 64 B. A new test pins the price to the library's view bytes, and the bands are recalibrated.crates/planner/src/installable/mod.rs: the wire version goes to 16.crates/executor/src/summary_kernels/dd_sketch.rs: q = 0 and q = 1 are no longer exact (see Behavior).Mechanical, skim only:
SketchAlgorithm::*across crates and their docs.sketch_plan_snapshots/*.json: names,definition_id(a hash that includes the name), and DDSketch bytes and costs.p90-kll.jsonlabels.Behavior: before → after
Workload: one PromQL
quantile_over_time(0.99, data[5m])evaluated every 10 s over 10,000 series, max error 5% (accepted as relative) (quantile-single-mvpinsketch_plan_snapshots, workloadworkloads/quantile-single.json). Run withasap_planner --run-until stage3 --format json --plan-file plan.json."summary_type": {"Sketch": "DDSketch"}; KLL plans:{"Sketch": "Kll"}{"Sketch": "KLL"}(Cms→CountMinSketch,Hll→HLL,Kmv→KMV,HydraCms→HydraCountMinSketch, …)wire_versionUnsupportedWireVersion(Some(15)))acceptedlineaccepted rank (Kll)(KLL plans)accepted rank (KLL)Executor answers change only at the DDSketch extremes. Sketchlib #252 removed the exact min/max, so quantile q = 0 and q = 1 now return the lowest or highest occupied bucket's representative (within α) instead of the exact min/max. Every other quantile is unchanged, and so is the relative-α guarantee the planner claims. No planner path answers
min/maxfrom a DDSketch:min_over_time/max_over_timeare exact aggregates.This keeps the planner on the same sketchlib main as the other repos (MVP correctness: one wire vocabulary).
Interfaces
Cargo.tomlcrates/planner/src/installable/mod.rsasap_types::summary_type::SketchAlgorithmis sketchlib's enum, re-exported, and serialized by variant name into plan files,--deployment-capabilitiesJSON (supported_summaries,exclusions) and the CLI document. Its variants as the planner sees them after this PR:/// A sketch family (asap_sketchlib::capability); stays. pub enum SketchAlgorithm { - Cms, + CountMinSketch, CountSketch, CountSketchWithL2Norm, - CmsWithHeap, + CountMinSketchWithHeap, CountSketchWithHeap, - CmsWithSpaceSaving, + CountMinSketchWithSpaceSaving, CountSketchWithSpaceSaving, - CmsFold, + CountMinSketchFold, CountSketchFold, - Hll, - HllHip, - Kmv, - Kll, - KllDynamic, + HLL, + HLLHip, + KMV, + KLL, + KLLDynamic, DDSketch, SpaceSaving, - Elastic, - Coco, + ElasticSketch, + CocoSketch, Bloom, SetAggregator, UnivMon, UnivMonTwoTier, UnivMonQ, - HydraCms, + HydraCountMinSketch, HydraCountSketch, - HydraKll, - HydraHll, + HydraKLL, + HydraHLL, HydraUnivMon, }The planner's own enums keep their names:
SketchParams::Kll { k }, θ textKll(k=547), and the JSON"parameters": {"Kll": {"k": 547}}.DDSketch's capability row gains
StatisticKind::QuantileInterpolated. The deployment file that lists every family therefore lists it too (tools/dag-viewer/deployment-capabilities/every-summary-family.json).Usage (from
crates/planner-cli/tests/sketch_plan_snapshots.rs,quantile-single-mvp):Algorithm changes
Cost model, DDSketch stored-state bytes (
crates/cost/src/node/state_bytes/mod.rs,ddsketch_state_bytes)sum,minandmax(3 × 8 B), but the price still charged an 88-byte header. A one-value state was priced at 100 B but holds 76 B. The new teststored_ddsketch_header_is_the_librarys_view_headershows this and failed first:priced 100 B, view layout 76 B.HEADER_BYTESgoes from 88 to 64. The rest of the formula is unchanged. The open (owned) state is priced throughsize_of::<DdSketch>(), which is already 24 B smaller.DdSketch::to_view_bytes().len() + 4from the library.stored_ddsketch_prices_never_fall_below_what_the_executor_holdsstill passes. The value-shape bands were recalibrated: held bytes fell by 24 B, so narrow-value ratios rose. Gauge and per-series 21.2→26.0, counter 22.9→28.7, declared per-series 12.2→14.9. The doc table was updated to match.memory_bytes_per_statestill replaces this estimate.Decisions and open questions
Needs reviewer decision
None.
Decided
shrink_to_fitnor the views. The executor needs both: it seals windows withshrink_to_fit, and its mapped state columns readDdSketchView/KllView/CountMinF64View. Branchplanner-pin/main-a05b35c-shrink-to-fit(01f3333) is:The port: the view layout drops sum, min and max; readouts follow main's nearest-rank and interpolated rules with no min/max clamp;
from_bytesbounds a store by the indexable bucket range (no slack, so every bucket of an accepted view reads back finite) instead of the samples' min/max;merge_viewrefuses a count overflow instead of panicking. asap-aware-mapping: whole-plan (cross-group) cost-based selection over the search's candidate-plan space #271's own copies of theshrink_to_fitcommits are replaced by SQL: lagInFrame/leadInFrame need distinct WindowFuncKind variants, not Lag/Lead #267 and feat(frontend-sql): model SQL window frame clauses (ROWS/RANGE BETWEEN ...) #270. asap-aware-mapping: whole-plan (cross-group) cost-based selection over the search's candidate-plan space #271 itself is still open and based on 21b6357; it needs the same rebase before it merges. The pin moves to plain main once SQL: lagInFrame/leadInFrame need distinct WindowFuncKind variants, not Lag/Lead #267, feat(frontend-sql): model SQL window frame clauses (ROWS/RANGE BETWEEN ...) #270 and asap-aware-mapping: whole-plan (cross-group) cost-based selection over the search's candidate-plan space #271 merge.INSTALLABLE_PLAN_WIRE_VERSIONfrom 15 to 16. These are sketchlib's names, not the planner's own, so they cannot stay stable without wrapping the enum. Rejected: a planner-side serde shim for old names (dead weight after one release).Verification
Run on the head commit, rebased onto main a51c623:
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features --locked -D warningscargo test --workspace --locked(CI's runner)cargo test --release -p asap-planner-cli --test corpus_snapshots -- --ignorednode --test tools/dag-viewer/stages.test.mjs tools/dag-viewer/memo.test.mjscargo test --all-featuresviews9,ddsketchlib 45,analytics156 passed (full suite 1418 passed at the earlier pin e074547)tests/views.rslayout offsets updated for the 64-byte headerAfter #1536 (view state key and plan id). Two IDs hash the
SketchAlgorithmnames, so they change for the KLL views in three snapshots: aMaterializedView'sdefinition_idand theplan_idbuilt from it. These arechains-10m-5m-3m-10s-mvp,sql-rollup-quantile-same-window-raw-retainedandsql-rollup-quantile-different-windows-raw-retained; all three were regenerated withUPDATE_SNAPSHOTS=1. The testview_state_key::the_view_state_key_of_a_planned_chain_is_pinned_and_round_trips_through_jsonpins the 5-minute KLL chain'sdefinition_id, which goes frombfbffb8f01ab202d585c3e18c9f78080to2d963bc6757b98ad80934456821cc040.materialized_views::PINNED_PLAN_ID(a Sum plan) is unchanged.New test:
stored_ddsketch_header_is_the_librarys_view_headerchecks that a one-row DDSketch state is priced at exactly the library's view bytes plus its 4-byte column offset.Changed tests:
dd_sketch::tests::quantile_interpolates_between_adjacent_order_statistics: q = 0 and q = 1 are now checked within α instead of exactly."accepted rank (KLL)",["KMV"],"CountMinSketch",Sketch(KLL).Sketch plan snapshot diffs (selected DAGs identical in every file; the check compares structure after normalizing names, costs and
definition_id):definition_id,plan_iddefinition_id,plan_iddefinition_id,plan_idCorpus goldens (
corpus_snapshots/): no diff.Follow-ups
KllView::from_bytesdoes not check that levels ≥ 1 are sorted (merging a forged view can corrupt the accumulator), andKllView::merge_view/rankcount fewer analytics ops thanKll::merge/rank.value_at_rankcomputes a bucket representative (powf) for every bucket it walks, not only the one it returns; q = 0 and q = 1 now walk the whole store since min/max were dropped. That belongs in sketchlib, not here.