Edge delta producer: guarantee delta ≤ full (min(full,delta) clamp) + decode-free / decoded-base caching - #459
Merged
Merged
Conversation
Rebased onto #457 (which extended the per-window empty-base delta producer to CMS/CountSketch/HLL). Adds the remaining piece: the delta-vs-full bandwidth invariant — a delta frame is never larger than the equivalent full frame at the same emit cadence. - min(full, delta) clamp in ComputeDeltaAgainst for all four delta-capable families (DDSketch, CMS, CountSketch, HLL): after computing the sparse delta, emit the full frame instead whenever the delta is not strictly smaller. The sketch full frames are themselves compact (DDSketch packs a contiguous positional count array; HLL uses a sparse-packed register encoding), so a naive indexed/per-register delta can exceed the full frame on dense (DDSketch) or low-cardinality (HLL) data — the clamp bounds it. Delta transmission stays OFF by default; this only changes what an enabled delta frame looks like. - docs: rename the design-alternative codenames to descriptive per-window-reset (PWR) / cumulative-epoch (CE). Tests: DDSketch per-window tests use sparse data for the delta path and a dense case asserting the clamp (payload ≤ full); HLL tests assert the clamp invariant in both directions and that per-window reconstruction never leaks the prior window. go test ./... green; edge processor builds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol
force-pushed
the
delta-invariant-producer
branch
from
May 26, 2026 19:32
4be4ee9 to
1c39355
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.
What
Makes the edge sketch producer (
asap-precompute-go) never emit a delta frame larger than the equivalent full frame at the same emit cadence — the delta-vs-full bandwidth invariant — and removes redundant per-window work on the emit path. Delta transmission stays OFF by default; this only changes what a delta frame looks like when enabled.Why
A delta is only a win when it's smaller. But the sketch full frames are themselves compact (DDSketch packs a contiguous positional count array; HLL uses a sparse-packed register encoding), so a naive sparse/indexed delta can be larger than the full frame for dense (DDSketch) or low-cardinality (HLL) data. Measured on the SERF/Chimp/Elf real-world datasets, HLL single-emit deltas ran ~2.5× the full frame. The producer now bounds this.
Changes
min(full, delta)clampDeltaFromEmptycomputes the per-window delta against a fresh empty base (decode-free — no deserialize of the cached base) and returns the full frame whenever the delta isn't strictly smaller.ComputeDeltaAgainstreturns full when the register-update delta isn't smaller than the sparse-packed full frame (corrects the prior "register deltas are never larger" comment, false at low cardinality).per-window-reset (PWR)/cumulative-epoch (CE).Testing
delta ≤ full, both clamp directions)go test ./...green; edge processor builds🤖 Generated with Claude Code