Exactly how “fast” are modern CPUs?

后端 未结 15 1983
深忆病人
深忆病人 2020-12-23 22:41

When I used to program embedded systems and early 8/16-bit PCs (6502, 68K, 8086) I had a pretty good handle on exacly how long (in nanoseconds or microseconds) each instruct

15条回答
  •  [愿得一人]
    2020-12-23 23:20

    A lot of good answers on this thread already, but one topic is so far unmentioned: branch misprediction.

    Because all modern processors are pipelined, when the instruction decoder runs into an instruction like "jump if equal", it has no idea which way the instruction will jump, and so it just guesses. It then continues feeding instructions into the pipeline based on that guess. If it made the correct prediction, the thruput and latency of the jump instruction is essentially zero. If it makes the wrong guess, the thruput and latency of the same jump instruction could be 50 or a 100 cycles.

    Note that the same instruction can have the "zero cost" the first time it's executed in a loop and the really huge cost the next time the same instruction is executed!

提交回复
热议问题