A performance pass workflow for AI pair programmers
Performance work with agents fails when optimization starts before measurement. A performance pass is a loop: baseline, hypothesis, change, re-measure, keep or.
Performance work with agents fails when optimization starts before measurement. A performance pass is a loop: baseline, hypothesis, change, re-measure, keep or revert. No anecdotes.
The trap is micro-optimizations and premature caching. Without budgets and profiles, agents complicate code for gains you cannot see, or for “wins” that miss the real bottleneck.
Ready for a performance pass?
Define the user-visible metric and environment up front. Lab-only wins that vanish in production are not wins. Check the harness into the repo next to the code it measures so agents and reviewers run the same command.
Measure → change one thing → re-measure

Measure Loop
Practical loop:
- Name the metric and scenario: p95 latency, allocation rate, bundle size, query count, plus hardware/env notes.
- Capture a baseline with the harness you will reuse after changes.
- Ask for hypotheses ranked by likely impact, tied to profile evidence, not generic tips.
- Implement one hypothesis. Forbid drive-by cleanups in the same diff.
- Re-measure with identical methodology. Keep only changes that move the metric beyond noise.
- Document in the PR: before/after, variance, and tradeoffs (memory vs CPU, readability).
Reject PRs that claim improvement without numbers in the template. Watch complexity taxes: a 2% gain that adds a fragile cache may be a net loss.
Three traps agents love

Failure modes to catch early
- No baseline. Optimize on vibes. Fix: refuse the pass until a number exists.
- Bundle five fixes. Attribution dies; revert is hard. Fix: one hypothesis per PR.
- Wrong bench. Microbench wins; users feel nothing. Fix: measure the user-visible path, including I/O wait.
When to run the pass

When this fits vs when it does not
On hot paths before releases, after architecture changes, and when SLOs threaten. Not as endless tinkering between feature work.
Bottom line
Measure first, change second, re-measure always. Agents accelerate a disciplined loop. They do not replace numbers.
Related: Measure coding-agent ROI without vanity metrics and Add observability with agents without noise spam.
Share