Skip to content

docs + test(sketchdb): proofs.md + accuracy empirical validation (#2.2 + #2.4) - #58

Merged
zzylol merged 2 commits into
mainfrom
docs/proofs-and-accuracy-bounds
Apr 21, 2026
Merged

zzylol merged 2 commits into
mainfrom
docs/proofs-and-accuracy-bounds

Conversation

@zzylol

@zzylol zzylol commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Two TODO.md #2 sub-items in one PR — both target paper §theory + §eval artifacts.

#2.4 — docs/proofs.md

New 245-line doc collecting:

  1. Accuracy bounds per sketch family — table + inline citations (Cormode-Muthukrishnan 2005, Charikar-Chen-Farach-Colton, Flajolet 2007, Karnin-Lang-Liberty FOCS 2016, Masson-Rim-Lee VLDB 2019, Metwally-Agrawal-El Abbadi ICDT 2005).
  2. combine_statistic correctness across schema-timeline segments — theorem + proof sketch.
  3. Write-barrier safety — no post-expire samples visible to any query.
  4. Backfill determinism — §10.5 invariants → bit-identical sketches.

Cross-refs added from accuracy.rs module doc-comment to docs/proofs.md.

#2.2 — accuracy empirical validation (+13 tests)

Paper-artifact regression guard on AccuracyProfile::derive:

  • Published-constant parity at canonical params (HLL p=14, CMS 3×1000, CountSketch 4×10_000, KLL k=200, DDSketch α sweep, CMS-with-heap).
  • Monotonicity sweeps — larger capacity → tighter ε (HLL, CMS ε + δ, CountSketch, KLL, DDSketch, CMS-with-heap heap_size).
  • Cross-family ordering check (CMS vs CountSketch at w=10k).

Live "measure sketch, compare to bound" sweeps live in sketchlib-bench's `sketchlib bench --metrics accuracy` output; this test pins the theoretical side.

Stats

788 → 801 tests green; clippy + fmt clean.

🤖 Generated with Claude Code

zzylol added 2 commits April 21, 2026 11:20
…rity + monotonicity sweeps

Addresses TODO.md #2 sub-item #2. Paper-artifact regression
guard on the `AccuracyProfile::derive` module:

## 1. Published-constant parity

Each sketch family's theoretical ε at a canonical parameter
matches the paper-published constant to ≥ 6 decimal places:

* HLL(p=14) = 1.04/√(2^14) = 0.008125 — Flajolet 2007
* CMS(w=1000, d=3) = e/w ≈ 2.718e-3 — Cormode-Muthukrishnan 2005
* CountSketch(w=10_000) = 1/√w = 0.01 — Charikar-Chen-Farach-Colton
* KLL(k=200) = 2.296/√k — Karnin-Lang-Liberty FOCS 2016
* DDSketch(α) passes through verbatim — Masson-Rim-Lee VLDB 2019
* CMS-with-heap combines CMS + retention — Metwally ICDT 2005

## 2. Monotonicity sweeps

Larger capacity monotonically tightens the bound — non-monotone
sweeps indicate a broken formula. Covered: HLL over precision,
CMS ε over width, CMS δ over depth, CountSketch ε over width,
KLL ε over k, DDSketch ε over α, CMS-with-heap ε over heap_size.

## 3. Relative ordering

Cross-family sanity: at w=10_000, CMS's ε (e/w ≈ 2.7e-4) beats
CountSketch's (1/√w = 0.01), confirming the two formulas
weren't accidentally swapped.

## Why no live sketch runs

The backend's `asap_sketchlib` git-dep exposes a different API
surface from sketchlib-bench's workspace path-dep (older
commit, pre-ErtlMLE/DataInput refactor). Bridging the two
inside a unit test couples to a specific dep pinning that
churns. Live "measure sketch, compare to bound" sweeps live in
sketchlib-bench's `sketchlib bench --metrics accuracy` output
and are compared to `AccuracyProfile::derive` via an external
script; this test pins the *theoretical* side of that
comparison so it doesn't drift.

## Tests

788 → 801 (+13), all non-ignored, clippy + fmt clean.
@zzylol zzylol changed the title docs(sketchdb): proofs.md — accuracy bounds + timeline / barrier / backfill theorems docs + test(sketchdb): proofs.md + accuracy empirical validation (#2.2 + #2.4) Apr 21, 2026
@zzylol
zzylol merged commit d7c896f into main Apr 21, 2026
@zzylol
zzylol deleted the docs/proofs-and-accuracy-bounds branch May 9, 2026 18:00
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