Intuition for optimizations
⚓ Rust 📅 2026-04-07 👤 surdeus 👁️ 1When optimizations are discussed it's not uncommon that someone will bring up that optimizations are not guaranteed.
Is it possible to develop some useful intuition for when certain optimizations are going to become less likely to be applied?
To my ignorant mind, things like inlining a lot, deeply nested function calls, with lots of for loops is probably going to exhaust some kind of "optimization context stack" at some point. But I have zero clue what I'm talking about.
The way "it's not guaranteed" is invoked sometimes, I get the impression that it's almost determined by the roll of a dice.
Could one construct a list of hand-wavy "How to be kind to your compiler" bullet points that are generally useful, or is it actually far more black magic than I think it is?
5 posts - 4 participants
🏷️ Rust_feed