Hook

This engineer just discovered a hack that gives us 12% faster CPUs by adding the number 3 to a file. Here's how that's even possible. Your code is full of tiny decisions. If this, do that. Else, do something else. When a chip hits an if statement, it has to stop and wait to know which path to take. Modern CPUs hate idle time, so they use branch prediction. They guess the outcome and through speculative execution start running that path early. Guess right, free speed. Guess wrong, the chip dumps that work and eats a penalty. Intel engineer Lily Cui found the exact setting inside GCC, the compiler that translates your code for the processor, that decides how costly a wrong guess should be. She added 3 to it. That's the whole change. With the penalty raised, all those borderline 50/50 guesses finally cross the threshold. The compiler stops writing them as risky jumps and uses branchless code instead, so the CPU throws away a lot less wasted work.
Their other posts in the index, biggest breakout first.