AgentStack
SKILL verified MIT Self-run

Rust Performance

skill-caraya-agent-skills-rust-performance · by caraya

Rust performance skill for profiling, benchmarking, allocation analysis, and optimization using criterion, perf, flamegraph, and cargo tools. Trigger phrases: Rust performance, benchmark, criterion, allocation, flamegraph, perf, slow compilation, SIMD, zero-cost abstraction.

No reviews yet
0 installs
5 views
0.0% view→install

Install

$ agentstack add skill-caraya-agent-skills-rust-performance

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Rust Performance? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Rust Performance

Use When

  • Profiling Rust applications for CPU, memory, or latency bottlenecks.
  • Benchmarking hot paths with criterion.
  • Analyzing allocation patterns and reducing heap usage.
  • Optimizing compilation time in large workspaces.

Profiling Tools

  1. Benchmarking
  • criterion: Statistical benchmarking library.
  • Add to Cargo.toml: criterion = { version = "0.5", features = ["html_reports"] }.
  • Run: cargo bench.
  • cargo bench (built-in): Simple benchmarks via #[bench] (nightly only).
  1. CPU profiling
  • perf (Linux): perf record -g cargo run --release && perf report.
  • Instruments (macOS): Use with cargo build --release and attach to process.
  • flamegraph: cargo flamegraph generates SVG flame graphs.
  1. Memory and allocation analysis
  • heaptrack (Linux): Tracks heap allocations with call stacks.
  • dhat (via valgrind): Detailed heap profiling.
  • jemalloc with stats: Use tikv-jemallocator for allocation statistics.
  1. Compilation performance
  • cargo build --timings: Generates HTML report of crate build times.
  • cargo llvm-lines: Shows which functions generate the most LLVM IR lines.

Checklist

  1. Benchmarking and baselines
  • Use criterion for reliable, statistically valid micro-benchmarks.
  • Always benchmark release builds (cargo bench uses release by default).
  • Establish a baseline before and after optimizations.
  1. CPU and hot paths
  • Profile with flamegraph to find high-CPU functions.
  • Avoid unnecessary clones, allocations, and copies in hot paths.
  • Use iterators with zero-cost abstractions; prefer iter() over manual indexing.
  1. Memory and allocations
  • Use cargo bench with --features dhat-heap to count allocations per operation.
  • Preallocate Vec and HashMap with with_capacity() when size is known.
  • Use Box, Rc, or Arc only at ownership boundaries, not for routine values.
  • Consider stack allocation or arena allocators for high-frequency short-lived objects.
  1. Compilation time
  • Use cargo build --timings to find slow-compiling crates.
  • Reduce generic monomorphization: avoid deeply nested generics in hot paths.
  • Split large modules into smaller crates to enable parallel compilation.
  • Use dylib for frequently rebuilt dev dependencies when appropriate.
  1. Async performance
  • Avoid blocking calls inside async tasks; use spawn_blocking for CPU-heavy work.
  • Minimize Arc> contention; prefer message-passing via channels.
  • Check task scheduling with tokio-console for stalls or starvation.

Output Requirements

For each finding provide:

  • Measurement (criterion output, flamegraph, allocation count).
  • Root cause (CPU, allocation, clone, async contention, compile time).
  • Optimization strategy with expected improvement.
  • Effort and risk assessment (safe vs. unsafe optimization).

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.