Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Systematically finds and fixes performance bottlenecks by measuring first, profiling hot paths, reducing algorithmic and I/O cost, and verifying gains with before/after benchmarks. Use this skill when code, an endpoint, a page, a query, or a job is "slow", "laggy", "timing out", "using too much CPU/memory", or "doesn't scale"; when asked to optimize, speed up, profile, or benchmark something; when chasing high latency / low throughput, p99 spikes, memory leaks, N+1 queries, or excessive allocati
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-21 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-15 | ✓→✓ | = Same ✓ | 76% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 60% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 78% | 0% |
Make slow things fast — correctly and provably. This skill enforces a measure-driven loop: never optimize on a hunch, always profile to find the real hot path, fix the biggest contributor first, then re-measure to confirm the win and guard against regressions.
Keywords: performance, profiling, optimization, bottleneck, latency, throughput, p99, slow, benchmark, flamegraph, CPU profile, memory leak, allocations, N+1 query, caching, big-O, complexity, hot path, regression.
The cardinal rule: measure first. Most "obvious" optimizations target the wrong code. Profilers routinely show that 90% of time sits in a place nobody suspected.
Follow this loop. Do not skip steps — especially step 1 and step 6.
wall-clock latency (p50/p95/p99), throughput (req/s, rows/s), CPU time, peak memory (RSS), or allocations. Write down the current value and the target. "Make it faster" is not a goal; "cut p95 from 800ms to under 200ms" is.
volume. A bottleneck at 10 rows may vanish at 10M and vice-versa. Disable noise: warm caches, JIT warmup, fixed input, quiet machine, multiple runs.
anything. Save the numbers. Use scripts/bench.py for a quick statistically sane wall-clock benchmark of a Python callable or shell command.
timers) to attribute cost. Find the function/line/query consuming the most time or memory. See references/profiling-tools.md for the right tool per language and how to read its output.
from the optimization hierarchy (see below). Change ONE thing at a time so each change's impact is attributable.
metric improved and correctness is unchanged. Quantify: "p95 800ms → 180ms, -77%". If no improvement, revert and re-profile.
target is met. Add a regression guard (a benchmark assertion or CI check) so the win doesn't rot.
Apply fixes in this order — cheapest/highest-leverage first. Most wins come from the top three.
logging in hot loops. Cache or memoize pure, repeated results. Hoist invariants out of loops. Compute lazily / short-circuit.
use a hash set/map for membership and lookups, sort once instead of repeatedly scanning, use the right data structure. See references/complexity-cheatsheet.md.
the right index, select only needed columns, stream instead of buffering, use connection pooling, paginate. I/O usually dwarfs CPU.
pool for CPU-bound work, vectorize (NumPy/SIMD). Only after single-thread work is minimized — parallelizing a bad algorithm just burns more cores.
collections, use generators/iterators, pick compact representations, cut GC churn.
tuned runtime flags, JIT-friendly code. Last resort — small payoff, high maintenance cost.
I/O (disk, network, DB, locks) — chase step 3/4, not micro-CPU tuning. If wall time ≈ CPU time, attack the algorithm (step 1/2).
help a single cold request's latency. Optimize for the metric you committed to.
caches, or a slow dependency — not the average path. Profile the slow requests specifically.
5% gain. Always spend effort proportional to a section's share of total cost.
release/optimized mode — never profile a debug build and extrapolate).
unrepresentative data/caching, then shipping a non-win.
references/profiling-tools.md — per-language profiler commands (Python,Node/JS, Go, Java, SQL, web/browser), what each measures, and how to read flamegraphs and call trees.
references/complexity-cheatsheet.md — big-O of common operations and datastructures, plus the canonical "swap this for that" optimization patterns (N+1 fix, set-membership, memoization, batching).
scripts/bench.py — runnable benchmark harness: times a Python expression ora shell command over N runs and reports min/median/mean/stdev with a clean comparison mode for before/after.
examples/optimize-n-plus-one.md — full worked example taking a slow endpointfrom 1.9s to 60ms through the whole loop (measure → profile → fix → verify).
Other measured skills in the registry, with their headline benchmark lift.