Skip to content

feat(gos): KLL insert-time emit trigger (R≥εN, reuses disjoint-segment mechanism) - #527

Merged
zzylol merged 1 commit into
mainfrom
split/pr-gos-kll
Jul 17, 2026
Merged

zzylol merged 1 commit into
mainfrom
split/pr-gos-kll

Conversation

@zzylol

@zzylol zzylol commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Part of the GOS per-family stack (base: CountSketch split/pr-gos-countsketch / #524). KLL is the simplest conversion — only the TRIGGER changes, the existing disjoint-segment emit-then-Reset() mechanism (subWindowSegmentMode/EmitSubWindow) is untouched. No sketchlib-go change (Count()/Reset() already suffice).

Trigger becomes insert-time R≥εN (derivations §8.6), where R is the sketch's own since-last-reset Count() and N is a new never-reset windowTotal counter on KLLWrapper. windowTotal survives Reset() deliberately — safe with no extra plumbing because Reset() on a live KLL wrapper only ever fires from the mid-window segment-emit path; a window-boundary rotation discards the whole seriesEntry and builds a fresh wrapper. SetGosMode(epsilon) takes no k (the formula has none).

applyGosMode KLL branch (distinct signature), subWindowShouldEmit Gate-1 bypass, subWindowMarkEmitted KLL no-op in GOS mode, factory priming, gos_delta_epsilon accepted for family=kll. KLL has no sampling path, so no #518 interaction.

Test plan

  • wrapper: wake fires at threshold not before, disabled-mode no-op, high-ε never-fires, segment-reset preserves windowTotal without double-counting.
  • processor: TestGOSKLLInsertWakesFlush (SubWindowInterval unset, WindowDuration 1h, ConsumeMetrics-only flush).
  • build/vet/test clean in both locations.

🤖 Generated with Claude Code

Convert KLL quantile sketches to the GOS insert-time model
(design-gos-unified-edge-telemetry.md §11; derivations doc §8.6): instead
of a periodic external-count divergence check, KLLWrapper now tracks its
own never-reset window-lifetime count N alongside the sketch's own
since-last-reset Count() (R), and arms a wake signal at insert time once
R>=epsilon*N.

This only replaces the TRIGGER. The existing disjoint-segment mechanism
(subWindowSegmentMode / EmitSubWindow's post-emit Reset()) is unchanged:
each GOS-triggered emit still covers exactly the data since the last
reset, and the backend still merges segments.

- sketches/kll.go: windowTotal (N, survives Reset), gosEpsilon, gosWake;
  SetGosMode(epsilon) (no k/sites term — KLL's trigger has none);
  ConsumeWakeSignal (wakeSignaler). Reset() clears gosWake but leaves
  windowTotal untouched (window-boundary rotations build a brand-new
  wrapper via the factory rather than calling Reset on a live one).
- precompute.go: applyGosMode gains a KLL branch (distinct SetGosMode
  signature); subWindowShouldEmit bypasses Gate-1 for GOS-mode KLL the
  same way it does for Count-Sketch; subWindowMarkEmitted's KLL case is a
  no-op in GOS mode (the trigger state lives in the wrapper already).
- warm_sketch.go: KLL factory primes SetGosMode at series creation.
- config_validate.go: gos_delta_epsilon now also accepts family=kll.
- gos_kll_test.go (both repos): wrapper-level wake/threshold/segment-reset
  proof, and a processor-level ConsumeMetrics-only end-to-end flush proof
  mirroring gos_countsketch_test.go.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the split/pr-gos-kll branch from 2decd92 to 7d81cd3 Compare July 17, 2026 02:45
@zzylol
zzylol changed the base branch from split/pr-gos-countsketch to split/pr-gos-sum July 17, 2026 02:45
@zzylol
zzylol changed the base branch from split/pr-gos-sum to main July 17, 2026 15:47
@zzylol
zzylol merged commit ee7b9ef into main Jul 17, 2026
@zzylol
zzylol deleted the split/pr-gos-kll branch July 17, 2026 15:52
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