Hook

This engineer just discovered a hack that gives us 12% faster CPUs by just adding the number three to a file. Here's how that's even possible. Your code is full of tiny decisions. If this, do something, else do something else. Normally 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 to guess the outcome. Then run that path early through speculative execution. Guess right, free speed. Guess wrong, the chip dumps that work and eats a penalty. An Intel engineer named Lili Cui found the exact setting inside GCC that translates processor code for the processor that decides how costly a wrong guess should be. She added three to it. That's the whole change. It updates the compiler's penalty score to match modern hardware. Now, every borderline 50/50 guess crosses the threshold, so the compiler stops writing risky jumps and uses branchless code instead. Loops and easy stuff. But the CPU throws a lot less wasted work and eats a lot less penalty. This is a one-line code change to the GNU Compiler Collection for its generic x86 tuning is benefiting modern Intel and AMD processors. Intel software engineer Lili Cui quite worthwhile increasing the cost of the generic x86 tuning for the. On the basis of modern CPUs having
Their other posts in the index, biggest breakout first.