rust-gamedev / wg

Coordination repository of the Game Development Working Group
514 stars 10 forks source link

Branch prediction hints (i.e. Likely/Unlikely) #49

Open aclysma opened 5 years ago

aclysma commented 5 years ago

In some performance sensitive code, hinting to the compiler that a certain path is likely or unlikely to be taken can be a helpful optimization:

There is a discussion here: https://github.com/rust-lang/rust/issues/26179

The RFC was accepted but the intrinsics are not stabilized, I think mainly because:

Workarounds:

mtak- commented 5 years ago

My crate nudge is possibly a good workaround for now. It does not require nightly.