Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions skills/benchmark-checklist/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
---
name: benchmark-checklist
description: "Verify benchmark rigor and performance claims using the Seven Performance Verification Questions before reporting numbers or declaring optimizations."
description: "Vet a perf measurement (limiter, tuning, limits, errors, repeatability, relevance, and whether the work happened) before you report or act on it. Use when you run a benchmark or report a speedup or regression you measured."
disable-model-invocation: true
---

# Benchmark Checklist
# Benchmark checklist

Verify every performance claim, benchmark run, or optimization result before reporting numbers. Never trust a single run or guess why code got faster. Answer the Seven Performance Verification Questions directly.
Use this when you produce a performance number: a PR's before and after, a regression claim, a hillclimb harness, or a library or config choice. Answer each question with evidence from a run, not a guess about the code.

## The Seven Performance Verification Questions
For a quick ballpark the user asked for, one run is enough. Still check questions 4 and 7, and say that it is one run. Skip the rest unless that run looks wrong. A choice between options is never a ballpark.

### 1. Limiter (Why not double?)
Ask why the improvement stopped where it did. Why not double the speedup? Name the physical bottleneck or limiter preventing 2x speedup (CPU instructions, memory bandwidth, cache line contention, disk I/O, network RTT, or thread synchronization). If you cannot name the physical limiter holding the ceiling, you do not understand the bottleneck.
## Before you run anything

### 2. Tuning (Production optimization flags)
Are production optimization flags enabled? Check compilation mode and environment flags. Confirm release mode is active (`-O2`, `-O3`, `--release`, or production build target). Verify debug assertions, sanitizers, trace logging, and developer devtools are disabled. A benchmark measured against an unoptimized debug build measures compiler accidents rather than software architecture.
- Write down the claim you expect to make, in the words you would ship ("export is 30% faster at p50 on the 60k-row dataset"). The questions test that sentence.
- Read the measurement script. Note what it times, counts, and ignores.
- Check the load average with `uptime` and the core count with `nproc` (or `sysctl -n hw.ncpu` on macOS). If the machine is busy, find out what is running. If you cannot stop it, interleave the sides so both see the same noise, and say so in the report.

### 3. Arithmetic Limits (Amdahl's law and bounds)
Calculate theoretical bounds before celebrating. Apply Amdahl's law to check the maximum theoretical speedup based on the fraction of execution time the optimized section occupied. If an optimized routine took 20% of baseline runtime, the whole system cannot speed up by 30%. Arithmetic checks prevent impossible speedup claims.
## The questions

### 4. Error Checking (Correctness under benchmark)
Check failure counts and verify correctness. Confirm error states, early bailouts, or skipped validation are not miscounted as fast executions. Inspect exit codes, response bodies, and error logs across the benchmark run. Fast execution that fails silently or returns early is a defect, not a performance win.
1. **Why not double?** Name the limiter. Profile in a run you do not report, because profilers and tracers slow the work down. Use CPU per process (`top`, `pidstat`), a runtime profiler (`node --cpu-prof`, `py-spy`, `perf`), I/O wait, and syscall counts (`strace -c` on Linux), then map the hot spot to source. Watch the load generator too: if it saturates first, you measured the load generator. If a change did not move the number, the limiter explains why, so find it before you call the change useless.
2. **Was it tuned?** Run every side the way production runs it: release builds, production flags and env, batching and transaction settings, connection pools, caches as warm or cold as production sees them, and the same versions and data. If one side runs on defaults, you compared configurations, not implementations. A limiter that is a setting (a commit per row, a debug build, a missing index) means that side is untuned. Tune it and measure again before you pick a winner. If you cannot tune it, do not pick a winner from that run. When the user is choosing what to adopt, narrowing the claim to the code as it ships today does not fix this, because they adopt the option, not today's settings.
3. **Did it break limits?** Do the arithmetic. Compare bytes per second with disk and network bandwidth, operations per second times cost per operation with your cores, and the time saved with the time the changed piece took. Removing a piece that takes 10% of the run can make the run at most about 11% faster. A result past a limit measured something other than the work, such as a cache, a no-op, or a bug.
4. **Did it error?** Count failures and non-success responses, and check that outputs are correct, not just present. Rejections are often fast, and timeouts and retries are slow. If the script does not count errors, add the count.
5. **Does it reproduce?** Run each side at least 5 times, alternating (A, B, A, B, and so on) so warmup, lazy initialization, caches, and drift favor neither. Report the median and range. A gap smaller than the run-to-run variation is no measurable difference. When the call is close, use a rank-sum test or the harness's own statistics.
6. **Does it matter?** Next to any micro result, measure the end-to-end path a user waits on, with realistic data sizes and concurrency, and report the micro result as a share of the whole. A helper that takes 1% of a request can make the request at most 1% faster, however fast the helper gets.
7. **Did it even happen?** Confirm the work ran inside the timed region: the request reached the server, the rows were written, the bytes were read, and the code used the result. Lazy code (generators nobody iterates, promises nobody awaits, results the JIT can discard) and timeouts produce numbers for work that never happened.

### 5. Reproduction (Variance and sample size)
Mandate running at least five runs. Record variance and median, not a single lucky run. Single-iteration spikes distort numbers through CPU frequency scaling, cold caches, background kernel interrupts, or JIT warm-up cycles. Discard cold starts if measuring steady state, report the median and standard deviation across five or more runs, and verify the gain clears noise.
## Report

### 6. Relevance (Microbenchmark versus whole-system)
Compare microbenchmark relevance to the whole-system realistic workload. Microbenchmarks isolate functions but miss cache eviction, memory pressure, context switches, and concurrent lock contention. Verify that microbenchmark improvements translate to end-to-end user-visible latency or throughput under realistic production data sizes and traffic shapes.
- Lead with the verdict: faster, slower, no measurable difference, or inconclusive.
- Give the number with its unit, the run count, the range, and the limiter. For example, "p50 41 ms → 33 ms, median of 7 runs per side, range 32 to 35 ms after, bound by JSON parsing on one core."
- Call the verdict inconclusive when you claim a difference but cannot name the limiter, when a side ran untuned, or when you could not check questions 4 and 7. Name the gap.
- Keep a PR body to one primary number. Deliver the full runs, range, and limiter evidence in the Antigravity Brain Artifact `<appDataDir>/brain/<conversation-id>/perf_report.md` (with `ArtifactMetadata` and `RequestFeedback: false`).

### 7. Lazy Execution (Confirm actual work executed)
Confirm the measured work actually executed. Ensure the compiler, optimizer, or runtime did not eliminate dead code. Prevent dead code elimination by consuming or asserting on benchmark outputs. Confirm asynchronous operations actually completed rather than leaving unmeasured deferred computation pending on an unpolled event loop.
## Other perf material

- Vet the **Perf issue** playbook's baseline before the playbook plans from it, and every number after that.
- Vet the **Hillclimb** playbook's harness before it is frozen. The frozen harness then prints error and work counts, so each keep-or-revert checks questions 4 and 7 for free.
8 changes: 4 additions & 4 deletions skills/create-verification-skill/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Answer these from the codebase and only ask the user what you cannot observe:

- **Surface:** what does a user actually touch? A web UI, a CLI/TUI, a desktop app, an API, a mobile app, a library? A repo can have several; pick the primary one and note the rest.
- **Run:** how does the app start locally? Prefer the repo's own documented dev command (package scripts, Makefile, README quickstart). Note ports, env vars, seed data, auth.
- **Drive:** how can an agent interact with it programmatically? Existing harnesses first: Playwright/Cypress specs, expect scripts, PTY helpers, curl-able endpoints, a debug port. For web and Electron, use native `browser_subagent` / CDP with repo-specific routes and selectors. For CLI/TUI, use a tmux/PTY harness. For services, use plain HTTP.
- **Drive:** how can an agent interact with it programmatically? Follow the Surface Precedence Hierarchy: existing harnesses first (Playwright/Cypress specs, expect scripts, PTY helpers, curl-able endpoints, a debug port); for CLI/TUI use a tmux/PTY harness; for services use plain HTTP; for web and Electron UIs use native `browser_subagent` / Chrome DevTools MCP with repo-specific routes and selectors.
- **Observe:** what evidence can be captured? Screenshots, terminal transcripts, response bodies, logs, exit codes, DB state.
- **Isolate:** can two instances run side by side (ports, data dirs, profiles)? If not, say so in the generated skill: refusing to double-drive a shared instance beats corrupting the user's session.

Expand All @@ -26,7 +26,7 @@ If the checkout doesn't build or start as-is, fix that first (or report it preci

Write `.agents/skills/verify-<app>/SKILL.md` with YAML frontmatter (`name: verify-<app>` and a `description` that names the app, the surface, and when to reach for it: without frontmatter the skill never registers) and these sections, each grounded in what the interview actually found (no placeholders left):

- **Launch:** the exact command that starts the app for verification, and how to tell it has reached a usable state (a log line, a UI render, a prompt). Include teardown. For a short-lived CLI or TUI there is no server to keep alive: launch means build the binary (or install deps) once, then start each drive in its own isolated PTY or tmux session.
- **Launch:** the exact command that starts the app for verification, and how to tell it has reached a usable state (a log line, a UI render, a prompt). Launch must reach a usable state from an empty data dir, including any migrations and seed data. Ready means usable, not just that a process answers. A database health check can pass while its init scripts are still running. Include teardown. For a short-lived CLI or TUI there is no server to keep alive: launch means build the binary (or install deps) once, then start each drive in its own isolated PTY or tmux session.
- **Doctor:** one read-only check that answers "is this instance worth driving?" - process up, right version/build, port owned by us, auth valid. An agent runs this first whenever anything looks off.
- **Drive:** the harness recipe with real selectors/commands from this repo, not examples. Prefer stable handles (ARIA labels, data attributes, prompt strings, route paths) over coordinates and tab order.
- **Evidence:** what to capture for a proof and where it goes. State the proof standards: exercise the real user path, not internal setters or test-only endpoints; capture the action and the resulting state, not just the final screen; verify side effects (files written, rows inserted, messages sent) alongside what's visible; mocks only where a production boundary already isolates the external system. When the safe path is a dry-run or test mode, verify what it actually skips by observing (files, network, git refs) rather than trusting its name: some dry-runs still touch the network or open a browser.
Expand All @@ -35,11 +35,11 @@ Write `.agents/skills/verify-<app>/SKILL.md` with YAML frontmatter (`name: verif

## 3. Seed the feature map

Create `.agents/skills/verify-<app>/features/README.md` plus one file per user-facing feature you can identify (aim for the top 3-5 to start, from routes, commands, menus, or docs). Follow the shape in [`references/feature-map-example/`](references/feature-map-example/), with a README index and one file per feature. Each file answers, from the user's point of view: what the feature is, how to reach it, how to drive it with the harness, and what observable end state proves it works. The four H2s are `Sub-features`, `How to get to it (user POV)`, `Driving it with <harness>`, and `Gotchas`. The map is the repo's maintained verification source; a proof that drives one convenient entry point is incomplete when the map lists others.
Create `.agents/skills/verify-<app>/features/README.md` plus one file per user-facing feature you can identify (aim for the top 3-5 to start, from routes, commands, menus, or docs). Follow the shape in [`references/feature-map-example/`](references/feature-map-example/), with a README index and one file per feature. Each file answers, from the user's point of view: what the feature is, how to reach it, how to drive it with the harness, and what observable end state proves it works. The four H2s are `Sub-features`, `How to get to it (user POV)`, `Driving it with <harness>`, and `Gotchas`. If the seed data lacks a precondition that a journey needs, the journey reports a failure and the reason goes in that feature's `Gotchas`. Never weaken the journey to make it pass. The map is the repo's maintained verification source; a proof that drives one convenient entry point is incomplete when the map lists others.

## 4. Prove the generated skill before handing it over

Run its own instructions end to end once: launch, doctor, drive ONE mapped feature (one is enough; the map exists so later runs can cover the rest), capture evidence, clean up. After cleanup, confirm the evidence still exists at the named location: a cleanup that eats the proof fails this step. Fix what fails, and run the generated cleanup after every failed iteration too, so broken attempts don't strand processes and ports. A generated skill that was never executed is a draft, not a deliverable.
Run its own instructions end to end once: launch, doctor, drive ONE mapped feature (one is enough; the map exists so later runs can cover the rest), capture evidence, clean up. After cleanup, confirm the evidence still exists at the named location: a cleanup that eats the proof fails this step. Fix what fails, and run the generated cleanup after every failed iteration too, so broken attempts don't strand processes and ports. A generated skill that was never executed is a draft, not a deliverable. If you proved it in a stand-in for the real target (a container in place of a fresh VM, a local stack in place of a remote one), list every setup step the stand-in did that the target will not. Those steps stay unverified until a run on the real target covers them.

## 5. Offer the maintenance loop

Expand Down
Loading
Loading