rust-performancelisted
Install: claude install-skill Lu1sDV/skillsmd
# Rust Performance
Optimize from evidence. Define the user-visible metric, reproduce the workload,
establish a stable baseline, profile the dominant cost, change one cause, and
prove both correctness and improvement.
## Quick Reference
Optimization priority — always fix the highest rung first:
```text
1. Algorithm choice 10x-1000x biggest impact
2. Data structure 2x-10x
3. Reduce allocations 2x-5x
4. Cache locality 1.5x-3x
5. SIMD / parallelism 2x-8x
```
Pick the measurement layer before touching code:
| Question | Tool |
|---|---|
| Is a pure operation faster? | Criterion / Divan microbenchmark |
| Did instruction-level cost change? | iai-callgrind (deterministic, CI-friendly) |
| Where is CPU time spent? | samply, `cargo flamegraph`, perf, Instruments |
| Where are allocations retained? | DHAT, heaptrack, allocator metrics |
| Why is the binary large? | `cargo bloat`, feature inspection |
| What drives compile time? | `cargo build --timings`, `cargo llvm-lines` |
| Does the service meet its SLO? | representative load test + observability |
A microbenchmark never proves end-to-end latency, overload behavior, or memory
bounds. Match the tool to the question.
## Workflow
### 1. Define the performance contract
Record workload, dataset, inputs, concurrency, platform, CPU/memory limits,
toolchain, target, features, allocator, build profile, warm-up, cache state,
and the success metric. Separate throughput from p50/p95/p99 latency, and
steady state f