Skip to content

chore(ddsketch): consume DDSketch wire format without metric scalars - #345

Merged
zzylol merged 1 commit into
mainfrom
chore/ddsketch-drop-scalars-consume
May 26, 2026
Merged

zzylol merged 1 commit into
mainfrom
chore/ddsketch-drop-scalars-consume

Conversation

@zzylol

@zzylol zzylol commented May 26, 2026

Copy link
Copy Markdown
Contributor

What

The DDSketch wire format dropped its DataPoint-level METRIC scalars (count/sum/min/max) in ProjectASAP/sketchlib-go#243 / asap_sketchlib#57. This updates ASAPQuery-backend to consume the trimmed format.

Changes

  • proto (crates/asap_otel_proto/proto/sketchlib_delta/ddsketch_delta.proto): DDSketchDelta keeps only buckets (1); tags 2-7 (d_count, d_sum, new_min, new_max, min_changed, max_changed) are now reserved. build.rs regenerates the prost bindings.
  • DDSketchAccumulator (dd_sketch_accumulator.rs):
    • from_sketchlib_proto_bytes calls the new 3-arg DdSketch::from_raw(alpha, store_counts, store_offset); count is derived from the bucket store via total_count().
    • apply_proto_delta_bytes applies bucket deltas only; count is recomputed from the merged buckets.
    • serialize_to_json drops the removed scalars (keeps bucket-derived count).
  • Decoders sketch_reducer.rs / delta_apply.rs and the edge_runtime_adapter.rs envelope encoder updated for the 3-field DdSketchState and total_count().

query_statistic — STRICT policy (as implemented)

  • Statistic::Quantile(q) → sketch-derived (unchanged).
  • Statistic::Count → derived from buckets (sum of store counts, exact).
  • Statistic::Sum / Statistic::Min / Statistic::Max → return the unavailable-statistic error (a Box<dyn Error> string error, not a panic, not 0). These statistics move to the controller-provisioned exact Sum / MinMax aggregations.

The query path handles this gracefully: query_statistic returns a Result, and DDSketchAccumulator uses the default empty aux_stats(), so Sum/Min/Max are not short-circuited by aux and the error propagates to the caller (which already treats it as a fallible result).

Tests

  • New query_statistic policy tests: Quantile + Count succeed; Sum/Min/Max return the unavailable-statistic error.
  • Existing round-trip / merge / delta / e2e fixtures rebuilt from buckets only (no scalars).

Dependency

Depends on ProjectASAP/asap_sketchlib#57 — CI green once that merges and the asap_sketchlib dep picks up the removed fields. Verified locally by temporarily repointing the asap_sketchlib path to the chore/ddsketch-drop-metric-scalars worktree (reverted before commit; the committed Cargo.toml keeps the normal ../asap_sketchlib path).

Test results (local, against the trimmed asap_sketchlib)

  • cargo build (lib + benches + examples + tests): green.
  • DDSketch unit tests: 13 passed.
  • DDSketch integration tests (edge_runtime_consumes_precompute_rs, e2e_controller_plans_and_backend_serves, e2e_modified_otlp_sketch_path): green.
  • Two pre-existing CMS/CountSketch *_zero_dims_rejected lib tests fail against the new asap_sketchlib branch because that branch also changed CMS error text — out of scope for this DDSketch PR; not touched here.

🤖 Generated with Claude Code

The DDSketch wire format dropped its DataPoint-level METRIC scalars
(count/sum/min/max) in ProjectASAP/sketchlib-go#243 / asap_sketchlib#57.
Update the backend to consume the trimmed format:

- proto: DDSketchDelta keeps only `buckets` (1); tags 2-7 reserved.
- DDSketchAccumulator:
  - from_sketchlib_proto_bytes / sketch_reducer / delta_apply now call
    DdSketch::from_raw(alpha, store_counts, store_offset) (3-arg) and
    derive count from the bucket store via total_count().
  - apply_proto_delta_bytes applies bucket deltas only; count is
    recomputed from the merged buckets.
  - serialize_to_json / edge_runtime_adapter drop the removed scalars.
- query_statistic STRICT policy:
  - Quantile -> sketch-derived (unchanged).
  - Count    -> derived from buckets (sum of store counts).
  - Sum / Min / Max -> return the unavailable-statistic error; these
    move to controller-provisioned exact Sum / MinMax aggregations.
    Default aux_stats() is empty for DDSketch so the query path falls
    through to query_statistic and propagates the error gracefully.
- tests: assert Quantile + Count still work and that Sum/Min/Max return
  the unavailable-statistic error (not a panic / 0); fixtures rebuilt
  from buckets only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit cdd7571 into main May 26, 2026
@zzylol
zzylol deleted the chore/ddsketch-drop-scalars-consume branch May 26, 2026 14:35
zzylol added a commit that referenced this pull request May 26, 2026
Align the backend's delta-apply with asap_sketchlib's updated wire format:

- HLL delta is now a varint-packed (index_delta, value) blob (was repeated
  per-register sub-messages). Decode + apply via HllSketch::apply_delta_bytes
  (single source of truth) instead of the vendored nested decode; vendored
  hll_delta.proto updated to bytes packed_updates; HLL round-trip tests build
  the packed blob.
- CountMinSketchDelta gained an hh_keys field upstream; pass an empty set on
  the CountMin apply path (no TopK to rebuild here), mirroring CountSketch.
- Update the CMS/CountSketch zero-dims decode tests to assert the current
  validate_sketch_dims message ('degenerate dims') surfaced by the bump.

DDSketch alignment (scalar-less wire) is already on main (#345/#346).
cargo build --workspace clean; cargo test -p data_plane --lib: 782 passed.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant