Repository navigation
Open
Description
Goal
Move ASAPQuery from the pinned asap_sketchlib rev 5158bf2 (v0.3.0 + 20 commits) to the published asap_sketchlib = "0.4.0". v0.4.0 removes the legacy MessagePack wrappers, MessagePackCodec, protobuf and serde on sketch types; ASAPv1 is the only serialized form. See the v0.4.0 changelog and ProjectASAP/asap_sketchlib#209 for the rename table.
Correctness first: query answers after the upgrade match the old code exactly unless a changelog entry explains the difference.
Steps
| # | What | Stacked on |
|---|---|---|
| A | Baselines on the current pin: per-sketch query outputs on fixed inputs, committed as test fixtures. No behaviour change. | main |
| B | Bump to 0.4.0 and fix every call site. One commit per area for review; only the last commit builds. Must reproduce A's baselines. | A |
- A
- B
Scope of B (one commit each)
- Set aggregators.
DeltaSetAggregatorAccumulatorbuildsSetAggregatorDelta(sketches::set_aggregator) and serializes withto_asapv1.SetAggregatorAccumulatormoves from its length-prefixed format toSetAggregator::to_asapv1.- Keys stay on
to_semicolon_str, as everywhere else in the engine; the encoding fix is query-engine: semicolon-joined group keys collide #912.
- Removed wrappers → native types, each checked against the old wrapper's source (parameters, defaults, hashing, query semantics), with the mapping written in the commit:
CountMinSketchwrapper → nativeCountMinSketchCountMinSketchWithHeap/CmsHeapItem→ nativeCountMinSketchWithHeap(TopKHeap/HeapEntry;i64heap counts;heavy_only→count_every_key); dropHeapItemReexportHllSketch/HllVariant→HyperLogLog*(ErtlMLE→Ertl)KllSketch→KllHydraKllSketch→HydrawithHydraCounter::Kll(query_quantile→query_cdf)
- Renames.
DDSketch→DdSketch;store_counts()→positive_store_counts()inaccumulator_factory.rs- PromSketch store:
EHSketchList→EhBucketSketch,KLL::init_kll→Kll::with_k,EHUnivOptimized→ExponentialHistogramUnivMon(update→update_weighted),calc_*→estimate_*,query_interval_merge→query_interval
- Deserialize. Every sketch accumulator gets a real
deserialize_from_bytesviafrom_asapv1. CMS-with-heap and HydraKLL return "not implemented" today, and DeltaSet reads a format it never writes. - Memory accounting.
memory_usage_bytesuses the nativememory_bytes()wherever it exists (at leastKll); keep the hand estimates elsewhere. - OTLP ingest.
otel.rsdropsproto::sketchlib::SketchEnvelope; the debug log usespeek_kind_id. The receiver forwarding nothing is tracked in query-engine: OTLP receiver never forwards metrics to the precompute engine #910. - Tests that reach into
.inner.engines/window_merger.rs,engines/simple_engine/sql.rs,tests/test_utilities/merge_fixtures.rs. - Debug script.
asap-tools/experiments/post_experiment/debug/read_dumped_precomputes.pydecodes ASAPv1. - Docs and comments. Stale references to old names (e.g.
aggregation_config.rsDDSketch comment, accumulator doc comments).
Tests
A (baselines). Deterministic synthetic streams per sketch accumulator:
- empty sketch (what a query returns)
- single item; duplicates
- negative values and zero (DDSketch)
- a NaN input (KLL)
- large weights
- merges of 2 and 3 parts, in more than one order
B, per sketch:
- A's baselines reproduce exactly. Any deviation must trace to a changelog entry and be checked against exact ground truth. Expected deviations:
- UnivMon cardinality / L2 fixes (PromSketch EHUniv)
- seed derivation for sketches with more than 20 rows
- HydraKLL, if
Hydrahashes subpopulation keys differently from the old wrapper
- Merge law: merging parts answers the same as one sketch over the whole stream.
- ASAPv1 round-trip:
deserialize_from_bytes(serialize_to_bytes(x))answers every query the same. - Error paths: wrong-type merge still
Err; poisoned serialize inmerge_fixtures.rsstillErr.
B, set aggregators:
- Round-trip keeps the same key sets.
- Byte-identical output for the same sets inserted in different orders.
- A key in both
addedandremovedmakesserialize_to_bytesreturnErr. peek_kind_idis08 00/08 80.
B, OTLP: a valid ASAPv1 payload logs its kind; garbage and truncated payloads log a decode error without panicking.
B, whole PR:
- Full suite passes;
cargo tree -i asap_sketchlibshows only 0.4.0. - Throughput before/after on a fixed ingest-heavy workload from
benchmarks/; a slowdown over 10% is discussed before merge.
Decisions
- Hard cutover. No backward compatibility for the old byte formats. Outside tests, nothing in the repo reads accumulator bytes back except the spill writer, which is write-only, and the debug script.
- Single dependency. Switch the pin to 0.4.0 directly; no side-by-side old/new dependency.
- Bytes. Correctness means query results and merges; the bytes only need to round-trip.
- Toolchain. v0.4.0 needs Rust ≥ 1.85; CI uses stable and the Dockerfiles use
rust:1.89. Nothing to change.
Out of scope
- OTLP receiver forwarding nothing to the precompute engine (query-engine: OTLP receiver never forwards metrics to the precompute engine #910)
- Lossless group-key encoding (query-engine: semicolon-joined group keys collide #912); done after this so the baselines isolate the upgrade
- Non-sketch accumulators' byte formats (sum, min/max, increase)
Activity