← Back to Pull requests

ci: benchmark the engine and report regressions against the base #233

Merged
abendrothj merged 13 files (449 lines) on Nov 21, 2026 18:14 UTC
View on GitHub
abendrothj abendrothj commented on Nov 13, 2026 11:04 UTC
Author

What and why

Part of #185 (P73): the Rust half; the browser half is #232. Stacked on #249.

  • Engine benchmarks (quackxide-engine/benches/query.rs): two research-style queries (count, filter) in QueryScope, each timing register, plan, execute and the disclosure gate (MinCountThreshold { k: 5 }), over synth-data's wide table at 10 000, 100 000 and 1 000 000 rows, and 1 000 000 rows in 8 objects. tests/bench_queries.rs checks both queries pass the gate and return rows.

  • Regression check (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.sh flags 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.sh lists the bench targets present at each commit, so a base without the engine bench works. The script's self-test runs in check.sh when jq is installed.

  • Targets in 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

  • A local run of the workflow's steps in CI order, with a deliberate 200 µs sleep added to the head's hpke_seal_to_tenant: every seal benchmark came out regressed and the comparison exited 1. Without the step that touches head sources first, cargo reused the base build and nothing was flagged.

  • A dry run with #228 as base: 14 crypto benches judged, the 8 new engine benches skipped, exit 0.

  • bench-compare.sh selftest: regressed, improved, within threshold, new benchmark, nothing compared, null and truncated estimates (errors, exit 2).

  • The compare step run with a stubbed exit 0, 1 and 2: 1 becomes a warning, 2 fails.

  • scripts/check.sh passes; cargo deny check passes.
  • Checklist

  • scripts/check.sh passes locally

  • Every new refusal has a negative test: n/a

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs: n/a

  • Fails closed on missing configuration, key material, or attestation: n/a

  • No new cryptographic primitives; suites stay behind their type aliases: n/a

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made: n/a
  • Diff: 449 lines (+415 / -34) across 13 files Reviewer: AxolDad Review duration: 11950m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.57) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 449 lines diff across 13 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.73 · 2 substantive comment(s)
    0.73
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Real PR Conversation Timeline
    6 items
    gabrielzubovsky gabrielzubovsky commented on Nov 14, 2026 21:49 UTC
    Reviewer

    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:

  • The engine table was recorded on an EPYC 7763 runner and the crypto tables on a 9V45. The absolute targets (e.g. 350 ms at 1 M rows) are about 1.5× one run, so a slower runner type could miss them with no code change. Fine as long as the targets are read as guidance and only the base-vs-head check gates.

  • git ls-files -z | xargs -0 touch to force cargo to rebuild the head is fragile, but the comment explains why. OK as is.
  • AxolDad AxolDad commented on Nov 17, 2026 00:53 UTC
    Reviewer

    @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_

    abendrothj abendrothj commented on Nov 17, 2026 05:28 UTC
    Author

    @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.

    abendrothj abendrothj commented on Nov 17, 2026 07:01 UTC
    Author

    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.

  • All 66 comparisons (22 benchmarks, 3 runs) were within threshold; no warning.

  • Changes ranged from −3.6 % to +3.9 %. The check looks at the low end of the 95 % interval, and the highest low end was +3.0 % (hpk2/seal/4MiB), so 10 % had about 7 points to spare. 5 % would also have passed these runs, with 2 to spare.

  • The 1M-row multi-threaded runs moved between −2.9 % and +3.9 %. The other noisy ones were the 4 MiB HPK2 seal (±3.6 %) and engine/count/10000 (up to +3.4 %). The 32 B, 4 KiB and keygen runs stayed within ±0.3 %.

  • Running the base first shows no lean: the mean change was −0.03 %, with 30 slower and 31 faster.

  • 23 of the 66 intervals exclude zero, so Criterion's own "regressed"/"improved" call fires on identical code about a third of the time. A size threshold is what keeps the check quiet.
  • 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>

    AxolDad AxolDad approved these changes on Nov 21, 2026 18:00 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    abendrothj abendrothj
    Labels
    risk: low confidence: 82.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57.1% (MEDIUM) · Higher = larger blast radius
    57.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.7% · Lower = rushed or shallow review
    82.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.9% · Safe to merge
    9.9%