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
rustc
does no speed/size optimizations (-C opt-level=0
). -
rustc
supports three levels of optimization for speed (-C opt-level=1
,-C opt-level=2
and-C opt-level=3
) and 2 levels of optimization for size (-C opt-level=s
and-C opt-level=z
). -
rustc -O
is equivalent torustc -C opt-level=2
andcargo build --release
uses 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.