CPU level 1 cache and level 2 cache depth analysis

CPU Cache: Through an optimized read mechanism, the hit rate of the CPU read cache can be very high (most CPUs can reach about 90%), which means that 90% of the data to be read next time in the CPU is in the cache. Only about 10% need to read from memory. This greatly saves the time for the CPU to directly read the memory, and also allows the CPU to basically read data without waiting.

In general, the order in which the CPU reads data is to first cache the memory.

The CPU core's integrated cache is called the L1 cache, and the outside is called the L2 cache. Later, with the continuous improvement of production technology, the final L2 cache is also moved into the CPU. Usually, the first level cache also includes a data cache (D-Cache) and an instruction cache (I-Cache). Both are used to store data and instructions to execute the data, and both can be accessed by the CPU at the same time, reducing conflicts caused by contention for the cache and improving CPU performance.

The first-level cache of the CPU is usually static RAM, and the speed is very fast, but the static RAM has a low level of integration (storing the same data, the size of the static RAM is 6 times that of the dynamic RAM), and the price is relatively expensive (same capacity. Static RAM is four times faster than dynamic RAM).

Enlarging static RAM as a cache is a less cost-effective approach, but in order to increase system performance and speed, it must expand the cache, which has a compromise: without increasing the original static RAM cache size, Only add some high-speed dynamic RAM as L2 cache. High-speed dynamic RAM is faster than conventional dynamic RAM, but slower than the original static RAM cache, and the cost is relatively modest. The contents of the L1 and L2 caches are copies (mappings) of frequently accessed data in memory, all of which exist to reduce high-speed CPU access to slow memory.

The second-level cache is one of the keys to the performance of the CPU. If the CPU core does not change, increasing the second-level cache capacity can greatly improve the performance. The difference between the high and low end of the CPU of the same core is often in the second-level cache, which shows the importance of the second-level cache to the CPU.

The CPU finds useful data in the cache called a hit. When the cache does not have the data needed by the CPU (this time it is called a miss), the CPU accesses the memory. In theory, in a CPU with a second-level cache, the hit rate of the read-level cache is 80%. In other words, the useful data found in the CPU level 1 cache is 80% of the total data, and the remaining 20% ​​is read from the L2 cache. Since the data to be executed cannot be accurately predicted, the read cache of the secondary cache is also about 80% (read from the secondary cache to 16% of the useful data). Then there is data that has to be called from memory, but this is a very small percentage.

The current higher-end CPU will also have a three-level cache, which is designed for reading missed data after reading the second-level cache. Among the CPUs with a three-level cache, only about 5% of the data is needed. Calling from memory, this further improves the efficiency of the CPU. In a sense, the improvement of the prefetching efficiency greatly reduces the production cost but provides a very close to ideal performance. Unless one day production technology becomes very strong, memory will still exist, and the cache's performance-increasing features will remain.

Electronics Wire

Shenzhen Hongyian Electronics Co., Ltd. , https://www.hongyiancon.com