Appearance
Performance Regression Bisect Quick Reference
One-line commands and threshold patterns for finding the commit that made things slow.
Quick start
bash
# Record baseline at known-good tag
git checkout v2.3.0
hyperfine --warmup 3 --min-runs 10 './bench.sh' --export-json /tmp/baseline.json
BASELINE=$(jq '.results[0].mean' /tmp/baseline.json)
# Run performance bisect via the automation script
scripts/bisect-perf-manage.sh run \
--good=v2.3.0 --bad=HEAD \
--worktree=/mnt/ramdisk/bisect-wt \
--threshold=5 --samples=5 \
scripts/bisect-perf.shManual bisect with hyperfine
bash
BASELINE=1.45 # seconds from known-good commit
git bisect start HEAD v2.3.0 --
# At each candidate, test and compare
hyperfine --warmup 3 --runs 5 --export-json /tmp/p.json './bench.sh'
CURRENT=$(jq '.results[0].mean' /tmp/p.json)
if (( $(echo "$CURRENT > $BASELINE * 1.05" | bc -l) )); then
git bisect bad
else
git bisect good
fiTest script template
bash
#!/bin/bash
set -euo pipefail
make -j"$(nproc)" || exit 125
hyperfine --warmup 2 --runs 5 --export-json /tmp/p.json './run-bench.sh'
CURRENT=$(jq '.results[0].mean' /tmp/p.json)
BASELINE=1.45
if (( $(echo "$CURRENT > $BASELINE * 1.05" | bc -l) )); then exit 1; else exit 0; fiThreshold strategies
| Strategy | Formula | When |
|---|---|---|
| Percentage | current > baseline * 1.05 | Simple, most common |
| Z-score | current > baseline + 3 * stddev | Auto-accounts for variance |
| Absolute | current > 500 (ms) | SLO-bound critical paths |
| Multi-criteria | Exit 1 if ANY metric exceeds its threshold | Latency + memory + binary size |
Noise reduction
bash
# Pin CPU governor (bare-metal or VM)
sudo cpupower frequency-set --governor performance
# Pin to single core
taskset -c 1 hyperfine --warmup 3 --runs 10 './bench.sh'
# Use RAM disk for worktree
git worktree add /mnt/ramdisk/bisect-wt HEAD
# ... bisect in /mnt/ramdisk/bisect-wt ...
git worktree remove /mnt/ramdisk/bisect-wt
# Drop caches for cold-cache tests
echo 3 | sudo tee /proc/sys/vm/drop_cachesLanguage-specific one-liners
bash
# Go: extract ns/op from benchmark output
go test -bench=. -benchtime=100x -count=5 ./pkg/foo \
| grep 'BenchmarkFoo' | awk '{print $3}' | sed 's/ns\/op//'
# Rust: extract ns/op from cargo bench
cargo bench -- bench_my_query \
| grep 'bench_my_query' | grep -oP '[\d.]+(?= ns/op)'
# Python: extract mean from pytest-benchmark JSON
jq '.benchmarks[] | select(.name == "test_query") | .stats.mean' /tmp/bench.json
# Node: hyperfine wrapping a node script
hyperfine --warmup 3 --runs 10 'node dist/bench.js'CI workflow (nightly detection)
yaml
- name: Performance bisect
run: |
LAST_GOOD=$(git tag --list 'v*' --sort=-version:refname | head -1)
scripts/bisect-perf-manage.sh run \
--good="$LAST_GOOD" --bad=HEAD \
--worktree=/mnt/ramdisk/bisect-wt \
scripts/bisect-perf.shPitfalls
- CPU scaling adds 15%+ noise. Pin the governor.
- JIT warmup needs 3+ discarded runs. Use
--warmup. - GC pauses inflate the mean. Use the median.
- Disk cache is cold on first run. Use
--warmup. - Never compare across different machines.
- Performance is not always monotonic. If results oscillate, bisect gives wrong answers.
Aliases
ini
[alias]
pbisect = !git bisect start && git bisect bad HEAD && git bisect good
pbisect-run = bisect runSee also
docs/devops-workflows/git-bisect-performance-regression.md— full advanced guidedocs/devops-workflows/git-bisect-run.md— correctness regression bisectscripts/bisect-perf-manage.sh— automation script