Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Optimization & High Performance
Cheap tricks for high-performance Rust
Optimizations: the speed size tradeoff
A performance retrospective using Rust (part 3)
Primitive Rust: a dive into structures
cargo-pgo Cargo subcommand that makes it easier to use PGO and BOLT to optimize Rust binaries.
Comparing Rust's and C++'s Concurrency Library
-
By default, the Rust compiler
rustcdoes no speed/size optimizations (-C opt-level=0). -
rustcsupports three levels of optimization for speed (-C opt-level=1,-C opt-level=2and-C opt-level=3) and 2 levels of optimization for size (-C opt-level=sand-C opt-level=z). -
rustc -Ois equivalent torustc -C opt-level=2andcargo build --releaseuses the release profile which defaults to-C opt-level=3. -
pass a 24-byte object by value vs by reference. not big differeence, but generally prefer passing by reference as it gives the compiler more flexibility for optimizations.