rust-performance

Measure and tune Rust CPU, heap, binary size, and build time with profilers and benchmarks.

2|1|Updated Aug 19, 2026
One-click install
npx skills add https://github.com/po4yka/rust-skills --skill rust-performance-po4yka
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-performance
Source: https://github.com/po4yka/rust-skills/tree/main/skills/rust-performance
Command: npx skills add https://github.com/po4yka/rust-skills --skill rust-performance-po4yka

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Rust workloads that run slowly, regress in benchmarks, grow in binary size, or build slowly need measurement before any code change, and this Skill provides the exact profiler commands, profile configurations, and verification rules to get trustworthy numbers on host, Android, and iOS. ## Core Features & Use Cases - Profiling setup and tool selection: Defines a symbolized profiling Cargo profile and routes to samply, cargo flamegraph, perf, simpleperf, Perfetto, Instruments, heaptrack, and DHAT per platform. - Benchmarking and CI gates: Covers Criterion and Gungraun baselines, the two-size scaling check that proves a benchmark measured real work, and regression gates that actually fail. - Size and build-time tuning: Uses cargo-bloat, cargo-llvm-lines, and cargo --timings to diagnose monomorphization bloat, then tunes LTO, codegen-units, opt-level, PGO, allocators, and rayon thread pools. - Use Case: A mobile app's Rust library grew after a dependency bump. Run cargo bloat --locked --profile <ship-profile> --target aarch64-linux-android --crates before and after, then use cargo llvm-lines on the top crate to find the new monomorphizations. ## Quick Start Ask the agent to profile your slow Rust binary with a flamegraph using the profiling profile and identify the hotspot.

Frequently Asked Questions about rust-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile a Rust application with a flamegraph?▼

Build with a dedicated profiling profile that inherits release, sets debug = true and strip = "none", then run cargo flamegraph --profile profiling --bin myapp. On Linux, set kernel.perf_event_paranoid to 1 or lower and pass -Wl,--no-rosegment when using rust-lld.

Criterion vs Gungraun for Rust benchmarks, which should I use?▼

Use Criterion 0.8 by default for wall-clock benchmarks with baselines and statistics. Use Gungraun, which measures Valgrind instruction counts on Linux, when you need a number immune to machine noise or an automatic CI regression gate.

Why does my flamegraph show hex addresses instead of function names?▼

Hex addresses mean the profiled build has no symbols. Cargo strips debug info in release builds, so build with --profile profiling where debug = true and strip = "none", and verify with readelf -S that debug_info sections exist.

How do I reduce Rust binary size with cargo-bloat?▼

Run cargo bloat --locked --profile <ship-profile> --target <triple> --crates before and after a change and diff the output. If generics dominate, use cargo llvm-lines to find high-copy functions and move bodies into concrete inner functions.

Can I profile Rust code inside an Android app?▼

Yes, use simpleperf for CPU profiles and Perfetto for system traces. The app must be profileable or debuggable, and symbolization needs the unstripped .so from target/<triple>/<ship-profile>/, not the packaged copy.

Why do my Criterion benchmark results swing between runs?▼

Swings over 10% come from thermal or scheduler noise; fix the power state and raise sample_size. Also verify the benchmark measured real work with a two-size scaling check, since LLVM can fold loops like (0..n).sum() into closed forms.