On the surface, we all know that the best processors are those that can do more with less, achieving the greatest speed possible without skyrocketing energy consumption. But once we cross the barrier of basic specifications, we discover that modern processors generally seek to pre-calculate, anticipate, and predict everything that passes through them. The YouTuber Matt Godbolt describes this through five very little-known aspects for the average user, which, despite their technical complexity, are fascinating.

Things You Didn't Know Your CPU Does for You (Video)
CPU

One of the first things anyone remembers about the early Atom processors is that they were slow as snails. In essence, Intel prioritized low power consumption over performance, applying a new architecture based on old concepts, and one of the things left behind was out-of-order execution.

What is it about? In relaxed terms, it is one of the many tricks that current processors have at their disposal to speed up the execution of instructions. Anyone trying to better understand these tricks will have to dive into the strange world of architectures, especially those developed by Intel. The alternative is to watch this video published by Matt Godbolt, which describes five of them:

Five Things a CPU Does

  • They try to guess how your data is accessed and recognize patterns, a form of prefetching that translates into a significant speed increase. In other words, they automatically load cache lines before you need them, staying a step ahead of the process.
  • They convert CISC («Complex» Instruction Set Computing) into RISC («Reduced» Instruction Set Computing). The operations of the first architecture are transformed into a series of “microcode” or “micro-operations” that can be programmed independently, gaining simplicity and efficiency.
  • They reorganize code execution. The order in which code is written is not the order in which it is executed by processors. The independence between blocks allows instructions to execute even while another group is waiting.
  • They convert code to SSA. Explaining SSA simply is an enormous challenge, but Godbolt reduces it to a series of optimizations that check whether the code is truly independent (essential for previous actions), and if not, rewrite it to acquire that property. In his example, he uses fictional registers like EAX1 and EAX2.
  • They predict the future. This is where the so-called branch predictor comes in, which, as its name suggests, has the task of anticipating whether a conditional jump will occur or not, classifying results as speculative. If the prediction fails, they are discarded. If it succeeds, they are already loaded. More speed.

In summary: data prefetching, conversion to microcode, out-of-order execution, register renaming, and branch prediction. If any of this reminds you of those bad boys called Spectre and Meltdown, it is because they in a way arise from weaknesses in these tasks. The relationship between speed and security requires a much more delicate balance than we imagined...

https://old.neoteo.com/como-trabaja-un-cpu/