# Rust Performance

> Use when optimizing Rust code or investigating slow builds/runtime — criterion benches, profiling, release flags, alloc pressure. Measure first; prefer official perf guidance.

- Skill: `tomjiu/rust-performance` (Agent Skill)
- Install (CLI): `npx skillmds@latest add tomjiu/rust-performance`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomjiu/rust-performance/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomjiu (https://skillmd.com/u/tomjiu)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/tomjiu/rust-performance

---


# Rust Performance

## Official / canonical

- The Rust Performance Book: https://nnethercote.github.io/perf-book/
- Cargo benches: https://doc.rust-lang.org/cargo/reference/profiles.html
- Local catalog: `E:\Code\skills\catalog\sources.yaml` → `languages_perf`

## Rules

1. Always use **`--release`** for runtime perf claims.
2. Prefer **criterion** (or built-in benches) over one-off `time`.
3. Fix algorithmic/IO issues before micro-optimizing.

## Commands

```bash
cargo build --release
cargo test --release
cargo bench

# CPU (Windows: use cargo-instruments on macOS; on Windows try cargo flamegraph / samply if installed)
# cargo install flamegraph
# cargo flamegraph --bin mybin

# Allocation / heap (platform tools vary)
# RUST_LOG=... for app-level timing first
```

## Checklist

- [ ] Baseline bench numbers recorded
- [ ] Profile under realistic input
- [ ] Hot function identified
- [ ] Change + bench delta reported
- [ ] Unsafe only with clear justification + tests

## Related

- `performance-optimization`
- `test-driven-development` for regression benches
- reverse/debug tools only if native ABI issues

