Article source: Click to open the link reason one: the distance is different
Distance is not the main factor, but it is best to understand, so put it on the front. The memory is CPU
far away, so it takes longer to read.
To3GHz
OfCPU
For example, the current can oscillate every second30
Billions of times, each time consuming about0.33
Na seconds. Light in1
In nanosecond time, you can move forward.30
Cm. In other words,CPU
Within a clock cycle, the light can go forward10
Cm. Therefore, if the memory distanceCPU
More than5
Centimeters, it is impossible to complete the reading of the data in a clock cycle, which does not take into account the limitations of the hardware and the current actually does not reach the speed of light. In contrast, registers areCPU
Inside, of course it will be quicker to read.
The distance to the desktop computer has a large impact on the phone is much smaller. Cell phoneCPU
The clock frequency is relatively slow (iPhone 5s
For1.3GHz
), and the phone's memory is next toCPU
。
Reason two: different hardware design
The new Apple company launchediPhone 5s
,CPU
IsA7
, The Register has6000
More than31
A64
Bit register, plus32
A128
Bit register). andiPhone 5s
The memory is1GB
, which is about80
Billion bits (bit
)。 This means that high-performance, high-cost, high-power designs can be used on registers,6000
Multi-bit, but not in memory. Because the cost and energy consumption of each bit is increased by just a little, it will be amplified80
Billion times.
In fact, the design of the memory is relatively simple, each bit is a capacitor and a transistor, and the register design is completely different, more than several electronic components. And after the power, register the transistor has been a power, and the memory of the transistor only used to have electricity, useless to the power, this is beneficial to power saving. These design factors determine that the register is faster than the memory read speed.
Reason three: different ways of working
Registers work in a very simple way, with only two steps: (1) Find the relevant bits, (2) read the bits.
The way memory works is much more complicated:
Pointer to the data that was found. (The pointer may be stored in the register, so this step includes the full work of the Register.) )
The pointer is sent to the Memory Management Unit ( MMU
) by MMU
translating the virtual memory address into the actual physical address.
The physical address is sent to the memory controller ( memory controller
), and the memory controller finds out which memory slot () it is on bank
.
Determine which memory block () The data is on chunk
, and read the data from that block.
The data is sent back to the memory controller, sent back CPU
, and then started to be used.
The workflow of memory is a lot more than the register. Each step creates a delay, which accumulates to make the memory much slower than the register.
To mitigate the huge speed differences between registers and memory, hardware designers have made a lot of effort, including CPU
setting up caches internally, optimizing CPU
how they work, and trying to read all the data from memory to the command at once, and so on.
Why is register faster than memory?