ci: benchmark the engine and report regressions against the base #233
Looks good. The regression rule (whole 95 % interval above +10 %) is sound and the selftest covers the edge cases, including the malformed-estimate errors. Minor notes:
git ls-files -z | xargs -0 touch to force cargo to rebuild the head is fragile, but the comment explains why. OK as is.@abendrothj reviewed at 840ad96 by reading the diff against #249; not run. Changes needed:
1. The gate compares against a stale base (bench.yml:73). github.event.pull_request.base.sha does not move when the base branch does, while the checkout is the merge ref against the current base. Changes other people merged in between are then charged to this PR. Benchmark HEAD^1 of the merge ref instead.
2. The gate passes when nothing was compared (scripts/bench-compare.sh:49). It prints "(no compared benchmarks)" and returns 0, so if the head run ever writes to another criterion directory the job is green for ever. Please fail in that case.
3. "Closes #187" is the wrong issue. #187 is "Hybrid KEM on the backend". Use "Part of #185".
4. Two things are stated as agreed that are not.
- docs/BENCHMARKS.md drops "Proposed, needs @AxolDad" from the targets and the threshold. Please keep the marker until they are agreed.
- #185 says pull-request runs report only and never fail; this makes them fail. Whether to change that is a maintainer decision, still pending. Until then the job stays report-only.
5. The 10% threshold is not calibrated for the engine benchmarks. The 1M-row multi-threaded ones have had no same-code comparison, and the base always runs first. Please show one run of identical code on both sides.
6. No timeout-minutes, on a job that took about 21 minutes.
7. The benchmark queries exist twice. tests/bench_queries.rs checks its own copy of the SQL, at 10 000 rows only.
8. Conflicts with its base. It also sits on #249 and #228, which both have changes outstanding.
Keep this job out of the required checks: it has path filters, so a required check would stay pending on PRs that do not touch backend/.
---
_Generated by Claude Code_
@AxolDad on your points:
1. The base is now the merge ref's first parent, so a moved or stacked base is compared correctly.
2. Nothing compared now exits 2 and fails the job; the selftest covers it.
3. Fixed: Part of #185.
4. The "Proposed" marker is back, and the job is report-only: a regression is a warning in the job summary, and the job fails only when the comparison can't run.
5. I'll post one identical-code comparison here, from a draft PR on top of this that changes only a comment, run a few times.
6. timeout-minutes: 45.
7. One shared query list for the bench and the test.
8. Rebased onto #249.
Also: #228's new crypto table broke the proposed keygen ratio. HPK2 keygen is now 5.8× HPK1, because the server's basepoint table sped up HPK1 keygen more. So the targets now hold keygen to its 1 ms bound and keep the ratios for seal and open.
Same-code calibration (point 5). #254 changes only a comment, so both sides of every comparison are identical code. I ran its bench job three times (run, attempts 1 to 3), which landed on three different CPUs: Xeon Platinum 8573C, EPYC 9V74 and EPYC 7763.
hpk2/seal/4MiB), so 10 % had about 7 points to spare. 5 % would also have passed these runs, with 2 to spare.engine/count/10000 (up to +3.4 %). The 32 B, 4 KiB and keygen runs stayed within ±0.3 %.Three runs is a small sample: this shows 10 % doesn't trip on ordinary noise, not that it never will. The threshold stays marked Proposed for your call. I'll close #254.
Also: "fuzz targets compile" had been failing here and on #249 since the restack, because the fuzz lockfile lost one line (base64 under platform-crypto). The fix is on #249 and this is rebased onto it.
<details><summary>Range per benchmark across the three runs</summary>
| Benchmark | Change | Highest lower bound |
| --- | --- | --- |
| engine/count/10000 | -0.9 % to +3.4 % | +1.7 % |
| engine/count/100000 | +0.1 % to +1.8 % | +1.1 % |
| engine/count/1000000 | -0.8 % to +0.0 % | -0.7 % |
| engine/count/1000000x8 | -2.3 % to +3.9 % | +1.5 % |
| engine/filter/10000 | -1.3 % to +0.3 % | -0.1 % |
| engine/filter/100000 | -1.1 % to +1.5 % | +0.7 % |
| engine/filter/1000000 | -1.1 % to -0.5 % | -0.9 % |
| engine/filter/1000000x8 | -2.9 % to +0.4 % | -1.2 % |
| hpk1/keygen | -0.1 % to +0.3 % | +0.0 % |
| hpk1/open/32B | -0.2 % to +0.1 % | -0.3 % |
| hpk1/open/4KiB | -0.3 % to -0.2 % | -0.3 % |
| hpk1/open/4MiB | -1.8 % to +0.6 % | +0.5 % |
| hpk1/seal/32B | -0.3 % to +0.1 % | -0.2 % |
| hpk1/seal/4KiB | -0.1 % to +0.0 % | -0.4 % |
| hpk1/seal/4MiB | -0.6 % to +1.4 % | +0.9 % |
| hpk2/keygen | -0.1 % to +0.1 % | -0.1 % |
| hpk2/open/32B | +0.0 % to +0.1 % | -0.1 % |
| hpk2/open/4KiB | +0.0 % to +0.2 % | +0.0 % |
| hpk2/open/4MiB | -1.7 % to -0.2 % | -0.5 % |
| hpk2/seal/32B | +0.1 % to +0.2 % | -0.2 % |
| hpk2/seal/4KiB | -0.1 % to +0.3 % | +0.0 % |
| hpk2/seal/4MiB | -3.6 % to +3.6 % | +3.0 % |
</details>
Approved these changes.
AxolDad
abendrothj
What and why
Part of #185 (P73): the Rust half; the browser half is #232. Stacked on #249.
quackxide-engine/benches/query.rs): two research-style queries (count,filter) inQueryScope, each timing register, plan, execute and the disclosure gate (MinCountThreshold { k: 5 }), oversynth-data'swidetable at 10 000, 100 000 and 1 000 000 rows, and 1 000 000 rows in 8 objects.tests/bench_queries.rschecks both queries pass the gate and return rows.bench.yml): on pull requests it benchmarks the base (the merge ref's first parent) and then the head in one job, on one runner.scripts/bench-compare.shflags a benchmark whose whole 95 % interval is more than 10 % slower as a warning in the job summary; the job fails only when the comparison can't run (nothing compared, malformed estimates). Report-only until gating and the threshold are agreed. 45-minute timeout. Not a required check.scripts/bench-targets.shlists the bench targets present at each commit, so a base without the engine bench works. The script's self-test runs incheck.shwhenjqis installed.docs/BENCHMARKS.md, proposed (marked so): absolute bounds and hybrid-to-classical ratios for seal and open, from #228's recorded run; key generation is held to its absolute bound. Engine targets and the engine table are filled from this PR's first run.While the stack is open, the base is #249's head, so the first run compares only the crypto benches (the engine bench is new). The check itself is shown working below.
How it was tested
hpke_seal_to_tenant: everysealbenchmark came outregressedand the comparison exited 1. Without the step that touches head sources first, cargo reused the base build and nothing was flagged.bench-compare.sh selftest: regressed, improved, within threshold, new benchmark, nothing compared, null and truncated estimates (errors, exit 2).scripts/check.shpasses;cargo deny checkpasses.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rs: n/adocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made: n/a