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.

tomjiu Updated

File contents

Rust Performance

Official / canonical

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

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

tomjiu/agent-skills-mcp/tree/main/selected/rust-performance commit 72c215982e

Frequently asked questions

npx skillmds@latest add tomjiu/rust-performance