Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Tips for Rust Optimization and Profiling¶
std::mem::size_of returns the stack size of a type.
memuse contains traits for measuring the dynamic memory usage of Rust types.
The Rust Performance Book has a comprehensive guide on optimizing Rust code. Rust Performance Pitfalls discusses about some performance pitfalls that you want to avoid.
rustfilt demangles Rust symbol names using rustc-demangle .
CPU Profiling¶
CPU profiling tools for Rust applications
Tool | Status | Rust-internal | Cargo / benchmark integration | Install & use | Speed | Comments |
|---|---|---|---|---|---|---|
Active | No (standalone command-line profiler) | None | Easy | — | Uses the Firefox profiler as its UI | |
Active | Yes (Rust crate) | Yes — integrates with Criterion; profile via | Easy (added as a crate dependency) | — | Internal perf tool; Criterion benchmarks by default, so | |
Active | No | Yes — via cargo-valgrind | Easy to install, configure and use | Slow | Much slower than not-perf | |
Low activity (last commit 2024) | No (based on Linux perf) | Yes — has cargo support | Hardest to install, configure and use | — | Relies on Linux perf | |
Active | Yes (Rust crate) | — | — | — | Friendly little instrumentation profiler for Rust | |
Inactive (last commit 2023) | No (standalone sampling profiler for Linux) | None | Very easy; no special configuration required | Fast |
Memory Profiling¶
Memory profiling tools for Rust applications
Tool | Status | Rust-internal | Cargo / benchmark integration | Install & use | Speed | Comments |
|---|---|---|---|---|---|---|
Active | No (ships with Valgrind) | None | — | — | Dynamic heap analysis tool that comes with Valgrind | |
Active | No (standalone profiler for Linux) | None | — | — | Heap memory profiler for Linux | |
Low activity (last commit 2025) | Yes (Rust crate) | Yes — used as a crate dependency | Easy (added as a crate dependency) | — | Heap and ad hoc profiling, similar to Valgrind’s DHAT | |
Inactive (last commit 2023) | No (standalone memory profiler for Linux) | None | — | — |