Hook
More breakout videos from this creator.
This engineer just discovered a hack that gives us 12% faster CPUs by just 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. Normally, when a chip hits one of those if statements, it has to stop and wait for the answer before it knows which path to take. Modern CPUs hate idle time. Instead, they use branch prediction. They guess the outcome of an if statement through speculative execution. They start running that path in advance. Guess right, free speed. Guess wrong, the chip dumps that work and penalty. An Intel engineer named Lily Cui found the exact setting inside GCC that decides how costly a wrong guess should be. She added 3 to it. Every time the compiler sees an if statement, it asks, is it cheaper to guess or to just answer directly? With the penalty raised, all those borderline 50/50 guesses finally crossed the threshold. The compiler stops writing risky jumps and uses branchless code instead. It still uses branching for predictable stuff like loops, but cutting out those high-risk gambles means the CPU throws a lot less wasted work.