r/programming • • Aug 22 '26

The unlikely Linux macro

https://rushed-reflections.bearblog.dev/an-unlikely-experiment/

Wrote a bit about the `unlikely` and `likely` macros in the Linux codebase. Great little exploration into tiny optimizations that everyone should know more about 😄

188 Upvotes

61 comments sorted by

View all comments

9

u/grekand46 Aug 23 '26

Rust got something similar a few months ago in the form of core::hint::cold_path, which is also a bit more flexible than likely and unlikely. Read more about it in the official doc if you're curious.

7

u/matthieum Aug 23 '26

I do note that Rust also offers likely and unlikely on nightly.