Rust Systems & Tokio (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is Link-Time Optimization (LTO) in Cargo?
senior LevelPerformance
In Simple Words: A compiler optimization technique enabled in release profiles:
- Standard compilation compiles crates into independent object files and links them.
- LTO (
lto = "fat"): Allows the LLVM compiler to perform optimizations (inlining, dead code elimination, devirtualization) across crate boundaries:- Significantly reduces binary size.
- Boosts runtime performance by 10-20% at the expense of longer compilation times.