The problem of cache and hit rate

(1) What is "Cache"

    Cache (ie cache memory) is a word we hear most often.

  (2) Why design Cache

    We know that the memory of the computer works at the clock frequency of the system bus, which is usually the FSB of the CPU (for Thunderbird and Dulong series processors, due to the use of DDR technology in the design, the FSB of the CPU is twice the system bus frequency). However, the operating frequency (main frequency) of the CPU is the product of the FSB and the multiplier factor. In this way, the operating frequency of the memory is much lower than the operating frequency of the CPU. The direct result of this is that after the CPU executes an instruction, it often needs to "wait" for some time to access the memory again, which greatly reduces the CPU's work efficiency. In such a case, Cache came into being!

  (3) What is Cache

    Cache is a special kind of memory, which consists of Cache storage part and Cache control part. The Cache storage component generally uses the same type of semiconductor storage device as the CPU, and the access speed is several times or even ten times faster than that of the memory. The Cache controller component includes a main memory address register, a Cache address register, a main memory-Cache address conversion component, and a replacement control component. As for how each of them works, what role they have, etc., there is no need to do further research, knowing that the general Cache is divided into L1 Cache (which is further divided into data Cache, code Cache), and L2 Cache.

  (4) How does Cache work

    We know that the CPU running program is executed one instruction at a time, and the instruction addresses are often continuous, which means that when the CPU accesses the memory, it tends to focus on a certain part in a short period of time. There are some subroutines that need to be called repeatedly. When the computer is working, these active subroutines are stored in the Cache which is much faster than the memory. When the CPU accesses the memory, it first determines whether the content to be accessed is in the Cache. If it is, it is called a "hit", and the CPU directly calls the content from the Cache; otherwise, it is called a "miss" , and the CPU has no choice but to Go to memory to call the desired subroutine or instruction. The CPU can not only read content directly from the Cache, but also write content directly into it. Since the access rate of the Cache is quite fast, the utilization rate of the CPU is greatly improved, thereby improving the performance of the entire system.

  (5) Application of Cache

    As early as the 486 era, the Cache slot was designed on the motherboard, and users could configure the Cache according to their own needs; some Caches were integrated into the 586-level CPU chip, and the Cache slot was also reserved for users to expand, and in the Pentium II era Later, the Cache has been fully integrated into the CPU chip, and there is no Cache slot on the motherboard anymore. Now the more popular CPU chips generally integrate at least 16KB of code Cache and 16KB of data Cache (as L1 Cache), and at least 64KB of L2 Cache.

Some friends may ask, since the role of Cache is so important, why not turn all the memory of the computer into Cache, isn't it better? In fact, for this problem, aside from the price factor, it is unnecessary in terms of its practicality. After all, when the computer is performing tasks, there are not many subroutines or instructions that are used very frequently, so those that are used less frequently High content just needs to be kept in relatively slow memory!

    In practical applications, Cache, especially L2Cache, has a great impact on the performance of the system, especially on the floating-point computing capability. And we know that the smooth running of most games requires frequent floating point operations. Therefore, the performance of CPU running games has a lot to do with the capacity and speed of L2Cache.

 

    The Chinese name of CACHE is cache memory, which is a word in French. I forgot what it means. It probably means hidden

    Compared with the memory, it is a storage system with small capacity and fast speed. It is implemented with static memory, which solves the problem that the memory cannot keep up with the computing speed of the CPU.

    The working principle is to copy a small amount of information that the CPU may use recently, which may be data or instructions, from memory to CACHE, so that the CPU can access these data at a higher speed and improve work efficiency.

The key index to evaluate the performance of CACHE is the hit rate of CACHE . Because the capacity of CACHE is much smaller than that of memory, it is only possible to store part of the data in memory. The CPU naturally accesses the cache first, and then accesses the main memory. If the data is hit in the cache, but not in the memory, there is a ratio problem. This ratio is the hit rate . There are several factors that affect the hit rate.

1. The capacity of CACHE, bigger is better

2. The unit amount (Cache Line Size) of each exchange of information between CACHE and the main memory is moderate

3. CACHE has different organization methods, and it is better to connect multiple groups

4. The multi-level organization of CACHE increases the hit rate

5. Word change algorithm after CACHE is full

To explain the problem of multi-level CACHE, simply say that the first-level CACHE is an image of the memory, which can improve the CPU speed, then adding another level of CACHE to the previous-level CACHE image can improve the efficiency again. At present, the CPU is usually 2-level CACHE, that is, L1 and L2

 Cache means cache

Many devices in the computer have Cache

Such as CPU, hard disk, CD-ROM, etc.

下面我们就来说说Cache的用途 CPU处理数据的时候是先从 L1 Cache 中 寻找 如果L1 Cache中没有所需要的数据CPU就从 L2 Cache 中寻找!如果L2 Cache中也没有所需要的数据那么CPU就会从内存中直接调用!但是内存的速度比Cache的速度低很多!如果让CPU频繁的从内存中直接调用数据,势必会造成处理速度极其缓慢!即使 CPU的运行速度再快也是没有用的!如果我们把CPU中的Cache增加一倍那么CPU就很有可能从多出的那一倍Cache中寻找到所需要的数据,这就是您所指的命中率!

知道了什么叫命中率我们就不难发现 如果是相同内核的CPU Cache的容量越大 CPU的运算性能就会越好!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326631983&siteId=291194637