performancelisted
Install: claude install-skill dean0x/devflow
# Performance Patterns
Domain expertise for performance optimization and bottleneck detection. Use alongside `devflow:review-methodology` for complete performance reviews.
## Iron Law
> **MEASURE BEFORE OPTIMIZING**
>
> Profile first, optimize second. Every performance claim requires benchmarks. Brendan
> Gregg's USE Method [1] (Utilization, Saturation, Errors) and Tom Wilkie's RED Method [2]
> (Rate, Errors, Duration) are the systematic starting points — not guesswork.
> Gil Tene's coordinated omission warning [8]: averages lie — monitor P99, not mean latency.
---
## Measurement Foundation [1][2][7][8][9]
| Method | For | Measures |
|--------|-----|---------|
| USE Method [1] | System resources | Utilization, Saturation, Errors per resource |
| RED Method [2] | Services | Rate, Errors, Duration per endpoint |
| Flame Graphs [9] | CPU hot paths | Widest frames = hottest code — optimize those |
| HDR Histogram [8] | Latency | Full distribution without coordinated omission |
**Latency hierarchy** [7]: L1 cache ~1ns · L2 ~4ns · L3 ~40ns · RAM ~100ns · SSD ~100µs · Network (DC) ~500µs · HDD ~10ms. Knowing these prevents optimizing the wrong layer [4].
---
## Performance Categories
### 1. Algorithmic Issues [5][12]
**N+1 Query Problem** — database query inside a loop. O(n) round-trips [5].
```typescript
// VIOLATION: 1 + N queries — O(n) round-trips [5]
for (const user of users) {
user.orders = await db.orders.findByUserId(user.id);
}
// CORRECT: Batch query with Ma