Why are registers faster than memory?

Source: Internet
Author: User

The computer's storage hierarchy (memory hierarchy), registers (register) the fastest, memory second, the slowest is the hard disk.

The same is the transistor storage device, why registers faster than memory?

Mike Ash wrote a good explanation and answered the question in a very popular way, helping to deepen the understanding of the hardware. Here is my simple translation.

Reason one: distance is different

Distance is not the main factor, but it is best to understand, so put it in the front. Memory is far away from the CPU, so it takes a long time to read.

In the case of a 3GHz CPU, the current can oscillate 3 billion times per second, each time taking approximately 0.33 nanoseconds. Light in 1 nanosecond time, can advance 30 centimeters. That is, within a clock cycle of the CPU, the light can advance 10 centimeters. Therefore, if the memory is more than 5 cm away from the CPU, it is impossible to read the data within a clock cycle, which does not take into account the hardware limitations and the fact that the current does not reach the speed of light. In contrast, registers are inside the CPU, and of course they read faster.

Distance for desktop computers, the impact on the phone is much smaller. The CPU clock on the phone is slower (the IPhone 5s is 1.3GHz), and the phone's memory is next to the CPU.

Reason two: different hardware design

Apple's new iphone 5s,cpu is A7, with more than 6,000 registers (31 64-bit registers, plus 32 128-bit registers). and the iphone 5s memory is 1GB, about 8 billion bits (bit). This means that high performance, high cost, high power consumption design can be used on registers, anyway, only more than 6,000, and can not be used in memory. Because each bit of cost and energy consumption just a little bit more, it will be magnified 8 billion times times.

In fact, the design of memory is relatively simple, each bit is a capacitor and a transistor, while the register design is completely different, more than several electronic components. And after the power, the register of the transistor has been electricity, and the memory of the transistor only to use the electricity, useless to the electricity, which is conducive to saving electricity. These design factors determine that registers are faster than memory reads.

Reason three: different ways of working

Registers work in a very simple way, with only two steps: (1) Finding the relevant bits, (2) reading these bits.

The way memory works is much more complicated:

(1) A pointer to the data is found. (The pointer may be stored in a register, so this step already includes all of the Register's work.) )

(2) The pointer is sent to the Memory Management Unit (MMU), which translates the virtual memory address into the actual physical address by MMU.

(3) The physical address is sent to the memory controller (memory controller), and the memory controller finds out which memory slot (bank) the address is on.

(4) Determine which memory block (chunk) the data is on, and read the data from that block.

(5) The data is first sent back to the memory controller, then sent back to the CPU, and then started to use.

There are many more steps to the memory workflow than registers. Each step creates a delay and accumulates to make the memory much slower than the register.

To alleviate the huge speed difference between registers and memory, hardware designers have made a lot of effort, including setting up caching within the CPU, optimizing the way the CPU works, and reading all the data from memory at once, and so on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.