Basic Caching Principles in the Memory Hierarchy

For the operating system, we know that the closer the memory to the CPU is, the faster its storage speed will be. If the entire storage system is regarded as a pyramid, and the CPU is the top of the tower, the access speed will be faster and faster from top to bottom. Slow, but the storage capacity is getting larger and larger, and the price is getting lower and lower. According to the commonly used storage systems, they are registers, caches, main memory, disks, and possibly network files.

In order to speed up the access speed, in each layer, the memory will be divided into continuous data object blocks, the general size is fixed (it may also be different, such as remote HTML files), the upper layer of each layer is used as the layer Because the access speed of the upper layer is faster and the storage capacity is smaller, the data object blocks of the upper layer will be less. Since the data object blocks are transmitted between layers, the cache of the previous layer at any time is a subset of the next layer. In addition, in order to compensate for the short board in access time, generally lower-level (ie away from the CPU) memory tends to use larger blocks. As for whether the subsequent cache hits, and which cache replacement policy control is used when the cache misses, it is another matter.

Supplement: The reason why the caching phenomenon is so "crazy" is because the program has locality, including temporal locality and spatial locality. The so-called temporal locality means that the same object may be referenced multiple times within a certain period of time. Spatial locality refers to the fact that the referenced objects often appear in a certain collection within a certain period of time. It is precisely because of this that the cache can be useful, because it temporarily stores the high probability of occurrence.

Guess you like

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