Skip to content

feat(bench): the cutover gate, and the rule it applies (#1296) - #1297

Merged
chappie-daemon merged 4 commits into
rewrite/mainfrom
factory/044-bench-gate
Nov 30, 2026
Merged

chappie-daemon merged 4 commits into
rewrite/mainfrom
factory/044-bench-gate

Conversation

@chappie-daemon

@chappie-daemon chappie-daemon commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What

src/scripts/bench-gate.ts is the gate #868's cutover reads. It takes two schema-2 benchmark
artifacts (one backend: "lmdb", one backend: "postgres") and decides:

  • each of the four REQ read shapes — by_id, author_kind, kind_since, tag — has its p95_us
    band within 1.5× of the Postgres band's, tested at the band median and at the failing edge
    (p90), each against the same bound (2·lmdb ≤ 3·pg, integer cross-multiplication);
  • create's per_second band is at or above 1× the Postgres band's, tested at the median and at
    p10.

An item whose median is inside the bound but whose failing edge is outside is a straddle, and a
straddle fails. Exit 0 pass, 1 fail, 2 refusal — one bench-gate: refused: <detail> line on
stderr, stdout always empty. A gated LMDB artifact needs workload.repeats >= 3; a Postgres
artifact needs at least 1 (a one-repeat Postgres artifact is legitimate and makes only the LMDB
edge testable). An artifact that records less work than its own corpus declares — a read-back
count short of its events, or a gated shape with zero rows — is refused before any band is
compared, because the rig writes the artifact before verify() runs. cpu_model, os and arch
are printed and not compared; a null cpu_model (a host with no /proc) prints as unknown.

docs/rewrite/benchmarks.md D8 carries the rule as the script defines it, the recorded run, and
what the gate does not cover yet (the Postgres column is #1132's host and must be the same host;
1M/10M need disk and a quiet box). The script's named constants are the rule's definition and D8
is their reading, each text pointing at the other. D3's opening sentence names the four
find_by_filters shapes and says count is count_by_filters.

The recorded run

$ node -r ts-node/register src/scripts/bench-gate.ts docs/rewrite/benchmarks/lmdb-50k-seed7.json docs/rewrite/benchmarks/lmdb-50k-seed7.json
bench-gate: refused: docs/rewrite/benchmarks/lmdb-50k-seed7.json: events 50000 is not a corpus the rule covers (covered: 1000000, 10000000)
exit=2

No Postgres artifact exists in the tree, so until #1132 produces one the gate can only refuse.

Tests

test/unit/scripts/bench-gate.spec.ts spawns the gate on artifact pairs built in a temp directory
— 29 rows / 33 cases, every case asserting exit status, exact stderr and empty stdout. The pass
fixture is spawned Postgres-first to prove roles come from backend; refusal cases each trip one
check a gate could plausibly skip. A25's two refusal rows are two cases each (one per artifact
side, one per gated kind) and A28's null-cpu_model fixture is one, which is where 33 comes from.

test/unit/scripts/bench-gate-units.spec.ts pins the exported pure functions in process (37
cases): the argument contract, role resolution, the repeat floors, run completion, band parsing,
both verdicts and the workload comparison.

  • mocha --require ts-node/register --reporter dot test/unit/scripts/bench-gate.spec.ts → 33 passing
  • the same with bench-gate-units.spec.ts → 70 passing (also green with ts-node type-checking,
    no TS_NODE_TRANSPILE_ONLY; the in-process file alone is 37 passing).
  • tsc --project tsconfig.build.json --noEmit → exit 0.
  • biome lint ./src ./test → exit 0 (3 pre-existing warnings in test/unit/ci/).
  • knip → exit 0.

Mutation checks: dropping the p90 edge test fails the two REQ straddle cases; reading p10 as the
median fails pg-band; ignoring the repeat floor turns repeat-below-min's refusal into a
verdict; removing the completion check fails A25's four cases (29 passing, 4 failing); restoring
the string-only machine check fails the null fixture (32 passing, 1 failing); dropping || rows < 0
from the row predicate fails refuses a gated shape whose row count is below zero (36 passing, 1 failing).

Note

R1's premise that knip derives entries from package.json scripts does not hold with this knip
version/config (Unused files (1) src/scripts/bench-gate.ts). .knip.json enumerates its entries
explicitly, so the file is added there beside scripts/benchmark-queries.ts; check:deps is green.

The read-back signal is the rig's top-level event_count_read_back (bench.rs:1188): volatile.store
carries only data_bytes/bytes_per_event and volatile.timings.read_back has no row count, so the
field the rig actually writes is the one the gate reads.

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e4a4731

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e11d96a5-d54c-4631-bd5f-b1be5e434466

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds a gate that compares LMDB and Postgres benchmark bands at the covered corpus sizes.

  • The benchmark gate compares LMDB runs with Postgres cutover limits.

Reviews (3) · Last reviewed commit: "fix(bench): refuse a negative row count ..." · Reviewed by Greptile

Comment thread src/scripts/bench-gate.ts Resolved
Comment thread docs/rewrite/benchmarks.md Resolved
@coveralls

coveralls commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 46361206591

Coverage increased (+0.2%) to 77.855%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 15 uncovered changes across 1 file (188 of 203 lines covered, 92.61%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/scripts/bench-gate.ts 203 188 92.61%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12317
Covered Lines: 10012
Line Coverage: 81.29%
Relevant Branches: 6495
Covered Branches: 4634
Branch Coverage: 71.35%
Branches in Coverage %: Yes
Coverage Strength: 750.13 hits per line

💛 - Coveralls

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 30, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 30, 2026 05:40

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

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.

2 participants