Skip to content

Benchmark fairness: query time, kept processes, tie-safe accuracy, honest periodic and planeval costs, measured sketch heap - #286

Merged
GordonYuanyc merged 11 commits into
mainfrom
benchmark-fairness-fixes
Dec 3, 2026
Merged

GordonYuanyc merged 11 commits into
mainfrom
benchmark-fairness-fixes

Conversation

@GordonYuanyc

Copy link
Copy Markdown
Collaborator

Measurement problems that made one system, arm or library look better or worse than it is. Each was checked against the code (and, where results exist, the 2026-12-01 archive) before the fix; one commit per problem, and every commit builds on its own.

# Where What was unfair What changes
1 One-shot speedup_over_* divided wall times, which for DuckDB, psql and PilotDB include starting a process every run (PilotDB also Python, its imports and a row count of every table); ClickHouse and Druid keep a connection Each engine names its query time, as ClickBench reports it: the engine's own timer for the three that start a process, the harness wall time otherwise. Speedups and the leaderboard data divide it; the wall columns stay. A query time of 0 (below DuckDB's 1 ms timer) gives no speedup
2 One-shot DuckDB and PilotDB started a new process every run, so every hot run began with a cold in-process buffer pool, while the servers keep theirs Both keep one process per configuration (DuckDB's shell reads queries from its input; PilotDB's driver serves one request per line and holds the database instance). restart() starts it again, so cold runs stay cold; a process that exits is started again. CPU from /proc around each run, peak memory from VmHWM reset through clear_refs
3 One-shot A query without GROUP BY or DISTINCT was compared by row position, so ORDER BY ties counted as errors (ClickBench Q25: the truth's own runs disagreed; exact engines showed 6–10 differing cells) Such rows match in value order; a query whose truth runs disagree gets no accuracy
4 Periodic ASAPQuery-backend instances that plan apart ran one after another and the peak took their max; queries VictoriaMetrics does not support were missing from its cost but not from the candidate's Peak = sum of instance peaks (largest kept alongside); each report lists the queries each system asked, latency over the queries both asked, and says when CPU and memory cover different queries
5 planeval state_bytes counted only sketch summaries, every other stored value 0; raw reads counted 16 B per sample without labels Every stored value by type, each sketch once however many rows share it; each evaluation also reports the label bytes of the series it read. (Batch::memory_bytes is not used: after a query reads a stored state it charges that state's sketches nothing)
6 planeval query_seconds included turning raw samples into executor rows and JSON-serializing every series' labels, which only raw-reading (exact) plans pay Timed apart as raw_batch_seconds, out of query and refresh time
7 planeval One run per evaluation, unpinned, no idle check --core, --runs (default 5), --warmup-runs, --max-core-busy; the query runs through Protocol::run_job_after (pin, idle check before and after, median), the refresh once under the same checks; run_use_case.py passes them on, answer-only callers run once
8 sketch-bench Timing was never idle-checked and mostly unpinned sketchbench --core pins and checks the core around every run (refuses a busy core before, marks one after); without it, or with --workers above 1, the record says NotPinned / IdleNotChecked. The repository's profile scripts pass --core
9 sketch-bench memory_bytes is each wrapper's own formula; heap-track was off by default and, when on, missed a sketch built before the clock started (it read 0) heap-track is a default feature and every pass is built on its own with the heap read before and after, so heap_bytes_peak is the heap the pass held once built plus what the run added
10 Periodic A system's cpu seconds is the server over the whole arm, ingest included; with several backend instances the data's ingest was charged once per instance ingest cpu seconds and query cpu seconds recorded apart (from the server CPU around every ingest and evaluation step), plus the largest instance's ingest, which is one ingest
11 Leaderboard, Grafana The leaderboard and the use-case runs did not carry what the fixes record Records gain query_time, query_cpu_seconds, ingest_cpu_seconds, ingest_cpu_seconds_one_instance, cpu_and_memory_comparable (known to schema.json); use-case runs record how planeval measured each arm

Not changed here, by decision: the items that were only partly true and the documented capability limits; psql still starts per run (PostgreSQL's buffer pool is the server's, and its speedup now uses \timing); the docs.

Before and after

origin/main and this branch, same machine, same settings, a few configurations each.

One-shot, ClickBench Q1/Q3/Q25/Q30, DuckDB and ClickHouse with 16 threads, PilotDB 5% on Q3/Q30, 4 runs:

hot median wall s, before → after speedup over DuckDB, before → after harness CPU s, before → after
DuckDB Q3 0.240 → 0.032 1 → 1 1.57 → 0.48
DuckDB Q30 0.320 → 0.043 1 → 1 1.68 → 0.47
ClickHouse Q3 0.062 → 0.062 3.88 → 0.50 –
ClickHouse Q30 0.102 → 0.102 3.15 → 0.41 –
PilotDB Q3 2.69 → 0.083 0.09 → 0.38 18.6 → 0.95
PilotDB Q30 3.02 → 0.40 0.11 → 0.11 18.0 → 1.19

Q25 had 9–10 differing text cells on every exact engine before; now it gets no accuracy (the truth's runs disagree). DuckDB's per-run peak memory now includes its kept buffer pool, as the servers' does.

planeval, use case 5, exact against noraw-ignore-eps0.05:

exact median query ms approx median query ms speedup
before (1 run, unpinned) 406.4 / 80.0 0.49 / 0.19 829× / 413×
after (5 runs, core 7) 197.6 / 50.5 0.41 / 0.10 480× / 512×

Of the old exact time, rebuilding raw batches was 159 ms / 27 ms per evaluation. Exact query memory now counts labels: 2.40 MB → 3.35 MB; the sketches' state bytes are unchanged (25,570 / 5,120).

Periodic, VictoriaMetrics against ASAPQuery-backend noraw-ignore-eps0.01 (backend at 8263b22b): use case 3 runs the backend in 5 instances; its peak was reported as 67 MB (the largest instance), now 305 MB (all five). Split from that run: backend 19.5 s ingest (4.5 s in its largest instance) and 5.7 s queries, VictoriaMetrics 12.1 s ingest and 10.1 s queries — the whole-arm 25.6 s against 23.4 s was mostly the data ingested five times. Use case 5 plans in one instance; its numbers moved within run-to-run noise.

sketchbench, 1M zipf items, insert: HyperLogLog lg_k=14 (sketchlib) measures 16,408 B against 16,400 declared (0 before), Count-Min 5×2048 (sketch_oxide) 81,992 against 81,920, Polars' exact baseline 8,388,656 against 8,388,608, KLL k=200 (sketchlib) 13,968 against 9,864. Insert throughput with and without heap-track: 29.0 / 29.1 M items/s (sketch_oxide HLL), 99.8 / 99.3 (Polars).

Checks: cargo fmt --check, cargo clippy --workspace --all-targets --all-features -D warnings, cargo test --workspace, cargo test -p system-bench --features planeval, the Python use-case tests; the real DuckDB and PilotDB adapter tests with AQPBM_DUCKDB / AQPBM_PILOTDB_PYTHON set.

🤖 Generated with Claude Code

GordonYuanyc and others added 11 commits December 3, 2026 03:14
DuckDB, psql and PilotDB start a process for every run, so their wall time
includes starting it (for PilotDB also Python, its imports and a row count
of every table), while ClickHouse and Druid keep a connection. Each engine
now names its query time: the time it reports for the three that start a
process, as ClickBench reports them, and the harness wall time otherwise.
speedup_over_* and the leaderboard data divide it; the wall columns stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each DuckDB and PilotDB run was a new process, so every hot run started
with a cold in-process buffer pool, while ClickHouse, PostgreSQL and Druid
keep theirs. Both adapters now keep one process for the whole
configuration: DuckDB's shell reads each query from its input, PilotDB's
driver serves one JSON request per line and holds a connection so the
database instance outlives each execute_aqp call. restart() starts the
process again, so cold runs still start cold.

The harness reads a kept process's CPU from /proc around each run and its
peak memory from VmHWM, reset through clear_refs before the run; a run in
which the process started or exited is not measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A query without GROUP BY or DISTINCT was compared row by row by position,
so a tie in its ORDER BY counted as an error: on ClickBench query 25
(ORDER BY EventTime LIMIT 10) the truth's own runs disagreed and every
exact engine had 6 to 8 differing cells. Such rows now match in value
order, and a query whose truth runs disagree gets no accuracy, as the
query does not fix its answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eries

When ASAPQuery-backend's queries do not plan together, each runs in an
instance of its own. The benchmark runs them one after another, but a
deployment runs them at the same time, so the peak resident bytes are now
the sum of the instances' peaks; the largest instance's stays alongside.

A query the reference system does not support is answered by the
in-process exact plan and is not in that system's latency, CPU or memory,
while the candidate's include it. Each report now lists the queries each
system asked, the latency of both over the queries both asked, and says
when their CPU and memory cover different queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
state_bytes counted only sketch summaries and charged every other stored
value 0, and raw data at query time counted 16 bytes per sample with no
labels. A stored state is now charged every value it holds, by type (8
bytes for a number or a timestamp, a string's length), and each sketch
once however many rows share it. Each evaluation also reports the label
bytes of the series it read, which run_use_case.py adds to the query
memory.

The executor's own Batch::memory_bytes is not used: once a query has
read a stored state, the batch counts its sketches as held outside the
run and charges them nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each evaluation turned the raw samples it reads into executor rows,
serializing every series' labels to JSON, inside query_seconds. Only the
plans that read raw samples paid it, so it raised the exact arm's latency
and the speedups against it. That time is now raw_batch_seconds, taken out
of query_seconds and refresh_seconds as compile time already was, and
run_use_case.py reports it as its own mean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
planeval timed every evaluation once, on whatever core the thread was on,
with no check that the core was idle. It now takes --core, --runs (odd,
default 5), --warmup-runs and --max-core-busy, as benchmark-external
does: each evaluation's query runs through Protocol::run_job_after
(pinned, idle-checked before and after, the median of the measured runs),
and the refresh, which changes stored state, runs once under the same
checks. Each cost records the core, the busy fractions and the marks.
Without --core nothing is pinned or checked and the cost says so.

run_use_case.py passes the four options on; the callers that only need
answers (the truth in run_use_case_on_systems.py, inject_errors.py) run
each evaluation once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sketch-bench timed every run on whatever core the thread was on and never
checked the core was idle; only run_throughput_fast.sh pinned it, from
outside. sketchbench now takes --core and --max-core-busy (default 0.10):
the measuring thread is pinned, the core's busy fraction is read before
and after every run (one run's after-sample is the next one's before), a
core busier than the limit before a run refuses it and after a run marks
it. Records carry the core, the largest busy fractions and the marks;
without --core, or with --workers above 1, they say NotPinned and
IdleNotChecked. run_profiles.sh and run_throughput_fast.sh pass --core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
memory_bytes is each wrapper's own formula (sketch_oxide's HLL is
1 << lg_k, Apache DataSketches' is its register count). heap-track was
off by default, and when on it measured only what the timed run
allocated, so a sketch built before the clock started measured 0.

heap-track is now a default feature of approxbench, and every pass is
built on its own with the heap read before and after, so each run's
heap_bytes_peak is the heap its pass held once built plus the most the
run added on top. Over 1M zipf items: HyperLogLog lg_k=14 (sketchlib)
16408 measured against 16400 declared, Count-Min 5x2048 (sketch_oxide)
81992 against 81920, Polars' exact baseline 8388656 against 8388608,
KLL k=200 (sketchlib) 13968 against 9864. A merge pass holds every
shard and a query pass its answers, so theirs are larger than one
sketch's memory_bytes. The counters are process-wide, so a run with
--workers above 1 leaves them out.

heap_track_leak now runs with the workspace's default features; its
deltas allow 1 KiB of other threads' allocations, which made it fail
about one run in eight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A system's "cpu seconds" is its server's CPU over the whole arm, ingest
and queries together. When ASAPQuery-backend's queries plan apart, every
instance ingests the whole data, so the sum of the instances charged the
data's ingest once per instance. On use case 3 (5 instances) the backend
summed to 25.6 s against VictoriaMetrics' 23.4 s, of which 19.5 s was
ingest repeated five times; its queries took 5.7 s against 10.1 s.

Each summary now also records ingest cpu seconds and query cpu seconds,
summed from the server CPU the harness reads around every ingest and
every evaluation step. A run in several instances adds the largest
instance's ingest, which is one ingest of the data, and says how many
times the data was ingested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fixes record more than the leaderboard and Grafana read. Each
leaderboard record now also has:

- query_time (one-shot): whether its speedups divide the engine's own
  time or the harness's wall time; results written before it existed
  divided wall time, so they say harness_wall.
- query_cpu_seconds, ingest_cpu_seconds and
  ingest_cpu_seconds_one_instance (periodic): the server CPU of the
  queries and of the ingest, the ingest summed over the instances and of
  the largest one.
- cpu_and_memory_comparable (periodic): whether both systems asked the
  same queries, so their whole-run CPU and memory compare.

schema.json knows the new keys, so the page does not warn about them,
and benchmarkRecord.js holds each to its benchmark. A use-case run of
run_use_case.py records how planeval measured each arm: the cores, the
query runs, the busiest core reading and the marks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GordonYuanyc
GordonYuanyc merged commit 19cc8e4 into main Dec 3, 2026
2 checks passed
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