feat(gos): KLL insert-time emit trigger (R≥εN, reuses disjoint-segment mechanism) - #527
Merged
Merged
Conversation
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
changed the base branch from
split/pr-gos-countsketch
to
split/pr-gos-sum
July 17, 2026 02:45
2 tasks
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.
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), whereRis the sketch's own since-last-resetCount()andNis a new never-resetwindowTotalcounter onKLLWrapper.windowTotalsurvivesReset()deliberately — safe with no extra plumbing becauseReset()on a live KLL wrapper only ever fires from the mid-window segment-emit path; a window-boundary rotation discards the wholeseriesEntryand builds a fresh wrapper.SetGosMode(epsilon)takes nok(the formula has none).applyGosModeKLL branch (distinct signature),subWindowShouldEmitGate-1 bypass,subWindowMarkEmittedKLL no-op in GOS mode, factory priming,gos_delta_epsilonaccepted forfamily=kll. KLL has no sampling path, so no #518 interaction.Test plan
windowTotalwithout double-counting.TestGOSKLLInsertWakesFlush(SubWindowInterval unset, WindowDuration 1h, ConsumeMetrics-only flush).🤖 Generated with Claude Code