Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on rustc

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)

The Magic of zerocopy

Primitive Rust: a dive into structures

Official Doc - std::simd

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

  1. By default, the Rust compiler rustc does no speed/size optimizations (-C opt-level=0).

  2. 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).

  3. rustc -O is equivalent to rustc -C opt-level=2 and cargo build --release uses the release profile which defaults to -C opt-level=3.

  4. 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.

References

Comments