Hook
More breakout videos from this creator.
this one number made EVERY CPU FASTER. 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. 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. They guess the outcome and through speculative execution, start running that path early. Guess right, free speed. Guess wrong, the chip dumps the work and eats a penalty. An Intel engineer named Lily Cui found the exact setting inside GCC, the program that turns your code into what your processor actually speaks, that decides how costly a wrong guess should be. She added 3 to it. That's the whole change. That plus 3 updated the compiler's penalty score to match modern hardware. Now every time the compiler sees an if statement, it asks, is it cheaper to guess or just calculate directly? With the penalty raised, all those borderline 50/50 guesses cross the threshold. The compiler stops writing them as risky jumps and uses branchless code instead. It still branches for predictable stuff like loops, but cutting out those high risk gambles means the CPU throws away a lot less wasted work.