Decide What a Fair Benchmark Must Reveal
A sketch benchmark is like a wind tunnel for compact streaming algorithms. A wind tunnel does not merely announce that one wing “won”; it controls the airflow, measures lift and drag repeatedly, records uncertainty, and exposes the conditions where the result changes. Likewise, the laboratory feeds known workloads to exact and approximate implementations, records accuracy and systems cost, and identifies the crossover where one design becomes the better engineering choice.
Suppose the true distinct count is 100. Three seeded trials estimate 96, 101, and 108. Their signed errors are −4, +1, and +8; relative absolute errors are 4%, 1%, and 8%. Reporting only the mean estimate 101.7 hides the 8% tail. A useful report gives the distribution, confidence interval, memory, update/query throughput, merge cost, and workload conditions. It also asks whether a stated 95% interval actually covers truth about 95% of the time.
A workload generator produces a versioned stream from parameters and a seed. An exact oracle computes ground truth with a method whose limits are understood. An error distribution is the collection of trial-level errors, not one average. Calibration compares nominal confidence with empirical coverage. Throughput is completed operations divided by measured steady-state time; latency distributions, CPU, allocation, and peak resident memory remain separate. Merge cost measures compatible partial-state combination. An adversarial case stresses assumptions such as uniform hashing, positive updates, order independence, or bounded cardinality.
Stakeholders are algorithm authors, platform engineers, SREs, capacity planners, reviewers, and product owners choosing a production sketch. Acceptance requires deterministic replay, independent exact truth, standardized adapters, repeated seeded trials, controlled warm-up and measurement, raw immutable results, environment fingerprints, statistically defensible summaries, resource guards, and a decision table tied to explicit SLOs and budgets.
A fair benchmark is a reproducible experiment that explains where a sketch succeeds, fails, and crosses over—not a race producing one attractive number. Accuracy, confidence, memory, throughput, latency, and merge behaviour must be measured under the same declared workload.
| Term | Intuitive meaning | Exact example | Non-example | Assumption | Question answered |
|---|---|---|---|---|---|
| Workload specification | Recipe for the stream | Zipf(1.1), N=1M, seed=42 | “Production-like data” | Generator/version is fixed | What exactly was tested? |
| Exact oracle | Ground-truth instrument | Python set for distinct count | Another HLL estimate | Oracle fits and is independently checked | What is the correct answer? |
| Trial | One isolated seeded run | Candidate A on seed 42 | Reusing warm state unknowingly | Setup/teardown is declared | What is one experimental unit? |
| Error distribution | Trial-level deviation pattern | p50=1.2%, p95=3.8% | Mean estimate alone | Trials represent target conditions | How variable and severe is error? |
| Calibration | Nominal versus observed confidence | 95% interval covers truth in 94.7% trials | Narrow interval with unknown coverage | Trials/seeds are independent enough | Can confidence metadata be trusted? |
| Throughput | Steady-state completed operations/time | 8.2M updates/s after warm-up | Loop iterations including setup | Timer and workload are controlled | How much work can the sketch sustain? |
| Peak memory | Maximum attributable working state | 1.3 MiB measured in-process | Serialized payload only | Allocator/runtime are recorded | What capacity does deployment need? |
| Merge cost | Time/bytes to combine partial states | 64 HLL shards merged in 4 ms | Rebuilding from raw events | States are compatible | Is distributed aggregation affordable? |
| Crossover | Region where preferred design changes | Exact set wins below 20k keys; HLL above | One universal winner | Decision weights are explicit | Which design fits this regime? |
Decide What a Fair Benchmark Must Reveal
Truth is 100; estimates are 96, 101, and 108. Compute signed errors −4,+1,+8, absolute relative errors 4%,1%,8%, median absolute relative error 4%, and worst case 8%. If the runs take 10, 12, and 11 ms for 100,000 updates, their throughputs are 10.0M, 8.33M, and 9.09M updates/s; report the individual trials before summarizing. Checkpoint: ranking by mean estimate alone favours the candidate because 101.7 looks close, but a 5% tail-error SLO fails. Reflection: what decision changes if the production objective values p95 error more than average throughput?
Design Workloads, Oracles and Reproducibility
The laboratory benchmarks counters, membership filters, cardinality estimators, frequency sketches, samplers, and quantile summaries through a common lifecycle: configure, update, query, merge, serialize, restore, and report state bytes. Users submit a declarative experiment containing dataset/generator version, distribution parameters, event count, seed schedule, sketch adapter/version, parameter grid, warm-up, repetitions, isolation mode, metrics, budgets, and acceptance rules. The scheduler expands this into immutable run manifests and sends them to isolated workers.
Workload families include uniform, Zipf, bursty, drifting, duplicate-heavy, ordered, shuffled, turnstile where supported, high-cardinality, heavy-tail latency, partitioned merge, and adversarial hash/counter cases. Exact oracles use integers, sets, dictionaries, sorted arrays, or reservoir inclusion accounting and are cross-checked on small fixtures. A result row contains manifest digest, seed, host/runtime fingerprint, timestamps, truth, estimate, error metrics, update/query/merge timings, peak memory, serialized bytes, status, and raw artifact checksums.
Target SLOs include deterministic regeneration of every workload, zero result mixing across manifest digests, 99.9% runner availability, run-start p99 below 30 seconds, ≤2% timing drift between calibrated reference runs on a stable pool, and hard CPU/memory/time quotas. Privacy rules default to synthetic data; production replays require minimization, access control, encryption, expiry, and provenance. Threats include malicious adapters, fork bombs, dataset exfiltration, clock manipulation, cherry-picked seeds, changed dependencies, corrupted artifacts, poisoned baselines, and over-parallelization that distorts measurements.
flowchart TD
U[Experiment author] --> V[Validate specification]
V --> X[Expand parameter grid]
X --> M[Immutable run manifests]
M --> Q[Resource-aware scheduler]
Q --> W[Isolated workers]
D[Generators and datasets] --> W
A[Sketch adapters] --> W
O[Exact oracles] --> W
W --> R[Raw trial artifacts]
R --> C[Statistical analysis]
C --> P[Decision report]
P --> G[Review and approval]
W --> T[Metrics traces audit]
classDef navy fill:#17365D,color:#fff,stroke:#102844;
classDef teal fill:#147D84,color:#fff,stroke:#0c5c61;
classDef crimson fill:#C6284D,color:#fff,stroke:#8e1935;
classDef purple fill:#6C3BAA,color:#fff,stroke:#482675;
class U,D,A,O navy;
class V,X,M,Q,W teal;
class R,C,P purple;
class G,T crimson;
| Candidate | Guarantee | Scale / latency | Memory | Operational burden | Privacy | Failure recovery | Decision |
|---|---|---|---|---|---|---|---|
| Ad hoc notebook | Flexible exploration | Small/manual | User-dependent | Hidden state and environment | Easy to leak data | Rerun if possible | Reject as authoritative; allow exploration only |
| Single-process harness | Deterministic local order | Good for small sweeps | Host-limited | Simple | Local controls | Restart whole run | Select for unit fixtures and developer smoke tests |
| Container per experiment | Environment isolation | Moderate startup cost | Quota per container | Image/version management | Stronger boundary | Retry immutable manifest | Select for standard reproducible trials |
| Process per trial | Strong trial isolation | Higher scheduling overhead | Hard per-trial limit | More orchestration | Limits adapter blast radius | Retry one trial | Select for untrusted or leak-sensitive adapters |
| Shared long-lived workers | Highest throughput | Low startup latency | Risk of state contamination | Warm-up/cache complexity | Weaker isolation | Worker recycle | Use only for calibrated trusted suites |
| Synthetic generators | Exact provenance and scale control | Very high | Streaming generation | Must model reality | No production data | Regenerate by seed | Select as baseline |
| Sanitized production replay | High ecological validity | I/O-bound | Dataset storage | Governance and drift | Highest privacy burden | Versioned immutable copy | Select only with approval and expiry |
| Mean-only report | Simple point summary | Cheap | Tiny | Misleading tails | Neutral | Easy | Reject |
| Raw trials + robust summaries | Auditable distributions and uncertainty | More analysis time | Artifact retention | Schema/version discipline | Govern raw fields | Recompute report from artifacts | Select as evidence model |
The central invariant is that every reported point is traceable to one immutable manifest, seed, adapter, oracle, environment, and raw trial. Launch is blocked by mixed digests, missing raw samples, unbounded execution, unverifiable truth, silent retries, or statistically unsupported rankings.
Build the Pluggable Experiment Harness
Build vertically. Slice 1 generates a seeded stream, computes exact truth, runs one adapter, and emits a raw JSON-compatible result. Slice 2 adds repeated seeds, error distributions, timing warm-up, and deterministic replay. Slice 3 adds parameter grids, merge trials, memory/serialization metrics, and isolated execution. Slice 4 adds artifact checksums, comparative reports, regression gates, and signed approvals. Each slice has a fixture whose expected digest and metrics are independently testable.
The adapter contract is intentionally small: create(config), update(key,value), query(request), merge(other), serialize(), and state_bytes(). Capabilities declare whether deletions, weights, merge, or confidence intervals are supported; the scheduler never invents unsupported operations. Run schemas are versioned. Resource validation happens before grid expansion and again before worker launch. Old results remain readable through explicit schema migrations; incompatible adapters are quarantined rather than coerced.
flowchart TD
S[Versioned run schema] --> G[Seeded generator]
G --> O[Exact oracle fixture]
O --> A[One adapter trial]
A --> R[Repeated seeds and raw rows]
R --> P[Parameter and merge sweeps]
P --> I[Isolated workers and quotas]
I --> E[Immutable evidence]
E --> C[Comparative canary report]
C -->|Gates pass| D[Publish decision]
C -->|Drift or invariant fail| B[Rollback baseline]
B --> O
classDef navy fill:#17365D,color:#fff,stroke:#102844;
classDef teal fill:#147D84,color:#fff,stroke:#0c5c61;
classDef crimson fill:#C6284D,color:#fff,stroke:#8e1935;
classDef purple fill:#6C3BAA,color:#fff,stroke:#482675;
class S,G,O navy;
class A,R,P,I teal;
class E,C purple;
class D,B crimson;
Build the Pluggable Experiment Harness: Sketch Benchmark Laboratory
Create schema.py, generators.py, oracles.py, adapters.py, runner.py, and report.py. Generate 5,000 uniform draws over 1,000 keys with seeds 3, 5, and 7. Checkpoint 1: repeated generation produces identical stream digests and exact distinct truth. Run an 8,192-bit linear counter; checkpoint 2 records three raw estimates, errors, update rates, and state bytes, with maximum relative error below 10% on the fixture. Split keys 0–99 across two compatible counters, merge, and require estimate error below 10%; reject a 1,024/2,048-bit merge. Expand a small parameter grid and verify stable manifest digests regardless of scheduling order. Exceed the work budget, corrupt one artifact, and omit a seed; each must fail visibly. Done means deterministic replay, exact truth, adapter conformance, merge verification, raw evidence, quotas, and report regeneration pass in one command.
Find Crossovers and Break the Candidates
Verification tests the laboratory before trusting what it says about sketches. Unit and property tests cover generators, seed isolation, oracle identities, adapter capability declarations, merge equivalence, serialization, quantiles, manifest hashing, and schema migration. Metamorphic tests shuffle insertion order for order-invariant algorithms, repartition mergeable streams, duplicate or scale weights where the mathematics predicts a response, and compare restored state with uninterrupted execution.
An approachable end-to-end study compares an exact set with linear counting from 100 to 1 million distinct keys, identifying the point where fixed bitmap memory beats the exact baseline while error remains acceptable. The professional matrix covers HLL, Bloom/Cuckoo filters, CMS/Count Sketch, reservoir sampling, and KLL/GK quantiles across uniform, Zipf, drift, heavy-tail, merge, and adversarial workloads. Each cell runs at least 30 preregistered seeds, reports p50/p95/p99 accuracy and latency, empirical confidence coverage, peak memory, serialized bytes, throughput, merge cost, failures, and cost per billion updates.
Failure injection kills workers mid-trial, throttles CPU, fills disk, corrupts artifacts, delays object storage, changes the clock source, poisons a baseline, leaks adapter state between runs, and schedules noisy neighbours. Metrics expose queue/run time, retries by reason, quota kills, host calibration drift, timer anomalies, artifact checksum failures, oracle disagreements, seed coverage, and report exclusions. Audit logs preserve manifest approval, adapter/dataset provenance, retry lineage, exclusions, baseline changes, and the final decision owner.
| Requirement / guarantee | Test oracle | Workload | Metric and threshold | Failure injection | Evidence | Owner |
|---|---|---|---|---|---|---|
| Workloads replay exactly | Stream digest | Every generator/seed | 100% digest equality | Generator dependency change | Golden digests and lockfile | Workload owner |
| Truth is correct | Independent brute-force fixture | Small exhaustive streams | Zero oracle mismatch | Corrupt oracle state | Cross-oracle report | Correctness lead |
| Adapter contract is honest | Capability/conformance suite | Update/query/merge/restore | Unsupported operations rejected; supported ones pass | Version and dimension mismatch | Conformance log | Adapter owner |
| Error claims are calibrated | Exact truth across seeds | 30+ trials per matrix cell | Empirical coverage within preregistered tolerance | Biased seed subset | Coverage curve and seed manifest | Statistics reviewer |
| Timing is stable enough | Host calibration benchmark | Repeated reference kernel | Drift ≤2% on stable pool | CPU throttle/noisy neighbour | Calibration series | Performance engineer |
| Resources are bounded | OS/container telemetry | Largest grid and state | Quota enforced before/at limit | Memory bomb and disk fill | Quota-kill audit | Platform lead |
| Merge behaviour matches contract | Single-pass reference | 1, 8, 64 partitions | Error/estimate within algorithm contract | Missing/incompatible shard | Merge matrix | Algorithms reviewer |
| Results remain reproducible | Artifact reanalysis | Published benchmark | Report regenerates from raw rows/checksums | Delete derived chart | Rebuild log and digests | Reproducibility owner |
| Runner recovers safely | Manifest/retry lineage | Worker loss mid-trial | No silent sample duplication; availability ≥99.9% | Kill worker/storage delay | Retry DAG and incident timeline | SRE |
| Private data stays governed | Access and expiry oracle | Sanitized replay | Zero unauthorized reads; expiry enforced | Forged dataset token | Security test and access audit | Privacy owner |
Find Crossovers and Break the Candidates: Sketch Benchmark Laboratory
Run a preregistered matrix across 6 algorithms, 8 workload families, 6 parameter sizes, and 30 seeds, with exact truth where feasible and shard counts 1, 8, and 64. Require complete seed coverage, zero oracle/conformance failures, reference-host timing drift ≤2%, reproducible report digests, enforced quotas, and each selected design meeting its stated p95 error, memory, throughput, and merge budget. At 20% progress throttle one worker; expect calibration quarantine. At 40% kill a trial and require lineage-preserving retry. At 60% corrupt one artifact; expect checksum exclusion and incomplete-cell failure. At 80% poison the baseline; expect review hold. Invalidate the recommendation for any cherry-picked seed, mixed manifest digest, missing raw sample, integrity failure, or unexplained regression. Record PUBLISH, CONDITIONAL, or INVALID with crossover plots, uncertainty, cost, exclusions, owners, and condition expiry.
Publish the Benchmark Dossier
The deliverable includes adapter and experiment schemas, generator/oracle specifications, parameter calculators, a pinned execution image, environment fingerprints, preregistration, immutable raw results, checksums, analysis code, comparative tables, crossover plots, calibration curves, benchmark report, correctness dossier, privacy review, incident notes, and an operational runbook. Every chart links back to raw rows and a manifest digest; every recommendation states its workload region, SLO weights, limitations, and rejected alternatives.
The runbook begins with queue delay, timing drift, oracle mismatch, quota kill, missing seed, corrupt artifact, adapter crash, storage outage, and baseline regression. It supplies diagnostics, exclusion rules, retry policy, escalation, invalidation criteria, and evidence-preservation steps. The demonstration regenerates a seeded fixture, runs exact and linear-counting adapters, shows raw error and memory rows, verifies compatible merge, rejects incompatible merge and excessive work, recomputes the report, then changes the decision weights to reveal a crossover.
Peer reviewers ask: Was the hypothesis and seed schedule fixed before results? Are workloads representative and adversarial? Is the oracle independent? Are warm-up, isolation, timing, and memory methods defensible? Are tails and failures visible? Does merging preserve the advertised guarantee? Can every figure be regenerated? Is the recommendation conditional rather than universal? Handoff requires tagged code/images, checksums, clean one-command replay, signed review, retained raw evidence, rehearsed incident handling, ownership, and no undocumented exclusions.
Publish the Benchmark Dossier: Sketch Benchmark Laboratory
Final checklist: (1) build the pinned image from a clean checkout; (2) run harness conformance, generator/oracle, replay, calibration, load, security, and fault suites; (3) freeze manifest and seed schedule; (4) archive raw rows, logs, checksums, environment fingerprints, and analysis code; (5) regenerate every table and figure; (6) sign correctness, statistics, performance, and privacy reviews; (7) rehearse retry, exclusion, invalidation, and recovery; (8) assign report and baseline owners. Demo deterministic replay, exact truth, an adapter sweep, error distribution, resource/cost table, merge trial, corrupted-artifact rejection, and crossover decision. Score 0–2 for validity, reproducibility, oracle quality, statistical treatment, performance method, operational safety, privacy, and decision usefulness; require ≥14/16 with no zero. Stretch goals: energy measurement, cross-language adapters, continuous regression bisecting, and hardware-normalized models. Milestones: reference suite, multi-host calibration, then continuously verified decision envelopes.
Publish only when raw evidence, exact truth, calibration, resource controls, provenance, and one-command regeneration survive independent review. Known risks include benchmark gaming, unrepresentative generators, correlated seeds, timer noise, private-data leakage, and universalizing a local winner; ask which changed assumption reverses the choice, then make continuous crossover-regression detection the next milestone.