Skip to content

Countmin restructure - #30

Merged
zzylol merged 2 commits into
mainfrom
countmin-restructure
Jan 14, 2026
Merged

zzylol merged 2 commits into
mainfrom
countmin-restructure

Conversation

@SieDeta

@SieDeta SieDeta commented Jan 14, 2026

Copy link
Copy Markdown
Collaborator

Replacing the old static implementation with a modular API (common, sketch) from sketchlib-go
https://github.com/approx-telemetry/sketchlib-go

@zzylol
zzylol merged commit db3e1bf into main Jan 14, 2026
@zzylol
zzylol deleted the countmin-restructure branch January 14, 2026 14:52
SieDeta pushed a commit that referenced this pull request Apr 17, 2026
zzylol added a commit that referenced this pull request Jun 27, 2026
…t 1)

asap-precompute-rs hardcoded sample_p=0.0 in all wrappers — it could decode a
sampled envelope (query-side rescale) but never PRODUCE one, so a Rust edge under
the CDM coordinator's ε-floor grant would ship unsampled full-rate sketches.

Mirror Go's coordinated path (precompute.SampleSetter, applyGrantedSampleP):
- New sampling.rs: GeometricSampler (NitroSketch geometric skip-sampling,
  splitmix64) + wire_sample_p (stamp 0.0 when exact for byte-parity, else p).
- SampleSetter trait in precompute.rs — implemented by exactly CMS, CountSketch,
  DDSketch (the additive families). Sum/KLL/HLL deliberately excluded, matching
  Go's switch in applyGrantedSampleP (HLL keeps its own hash-threshold path).
- Each of the 3 wrappers: sample_p field + GeometricSampler, with_sample_p builder
  + set_sample_p (reseed), admit-gate in update(), stamp wire_sample_p in the
  envelope, reseed on reset(). Seeds mirror Go (cms ZMPC / cs 0x5a3e06d / dd DDSP).
- Count sketches rescale by 1/p on query; DDSketch is scale-invariant (samples to
  shed work, no rescale) — both still stamp p.

Exact path unchanged: sample_p stays 0.0 → #243 byte-parity preserved (all 57+11+27
tests green). New test asserts admit≈p fraction + envelope stamp + SetSampleP.

Part 2 (runtime hook: derive p from the engine's granted ε-floor and install the
window sample-hook, mirroring Go's applyGrantedSampleP wiring) is a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jun 27, 2026
…antile (#30)

Locks in the quantile case: sampled DDSketch admits ~p of updates (total_count ~p×)
but its quantile shape survives (scale-invariant, no 1/p rescale), and the envelope
stamps p while the exact path stamps 0.0 for byte-parity.

Co-Authored-By: Claude Opus 4.8 <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.

2 participants