Performance Optimization
Measure the bottleneck before optimizing it.
Workflow
- Define the user or system target: p50/p95/p99 latency, throughput, startup,
memory ceiling, frame budget, bundle size, query cost, or error budget.
- Build a representative and repeatable workload with realistic data,
concurrency, cache state, network, and device assumptions.
- Capture a baseline with profiler, trace, query plan, browser performance
panel, bundle analyzer, or resource metrics. Record variance and warm/cold
state.
- Rank bottlenecks by user impact and cost. Form one falsifiable hypothesis.
- Make the smallest change, rerun the same workload, and compare effect and
regressions. Keep only improvements that meet the target without violating
correctness, accessibility, cost, or operability.
- Add a regression budget/check where the risk is likely to recur.
Read measurement.md. Do not optimize a benchmark
that does not represent the user path, hide work by weakening correctness, or
claim improvement from one noisy run.
Completion condition
The bottleneck, baseline, change, before/after result, variance, trade-offs,
and remaining limits are documented.
1---2name: performance-optimization3description: Diagnoses and improves measured latency, throughput, memory, CPU, bundle, rendering, query, or resource performance by defining a target, profiling a representative workload, locating the bottleneck, making one change at a time, and comparing before/after evidence. Use for performance work or regressions. Not for guessing optimizations without a reproducible workload or for generic refactoring.4---56# Performance Optimization78Measure the bottleneck before optimizing it.910## Workflow11121. Define the user or system target: p50/p95/p99 latency, throughput, startup,13 memory ceiling, frame budget, bundle size, query cost, or error budget.142. Build a representative and repeatable workload with realistic data,15 concurrency, cache state, network, and device assumptions.163. Capture a baseline with profiler, trace, query plan, browser performance17 panel, bundle analyzer, or resource metrics. Record variance and warm/cold18 state.194. Rank bottlenecks by user impact and cost. Form one falsifiable hypothesis.205. Make the smallest change, rerun the same workload, and compare effect and21 regressions. Keep only improvements that meet the target without violating22 correctness, accessibility, cost, or operability.236. Add a regression budget/check where the risk is likely to recur.2425Read [measurement.md](references/measurement.md). Do not optimize a benchmark26that does not represent the user path, hide work by weakening correctness, or27claim improvement from one noisy run.2829## Completion condition3031The bottleneck, baseline, change, before/after result, variance, trade-offs,32and remaining limits are documented.