What is CPU cache and what is it for? Explained
CPU Cache memory is a small and fast temporary storage area located near or on the CPU itself For efficient easy and near instant data retrieval .
The CPU cache is an internal memory of the processor that is inserted into it. Unlike RAM memory, SSDs or HDDs, it cannot be replaced, changed or expanded, it is a resource of the processor or CPU itself that is physically implanted on the same PCB. As can be seen from its name, it is a type of cache memory, extremely fast and with very little capacity, that is used by the processor and all its cores to obtain frequently used information in a much more efficient and faster way than if it were obtained from other types of storage such as RAM or SSDs.
What is CPU cache?
Cache memory isn’t a computers primary memory, nor is it even permanent. But its quite important to computer performance.
Unlike computers large and slow main memory cache momory is a small and fast temporary storage areas located near or on the CPU itself For efficient easy and near instant data retrieval .
CPU cache levels
The CPU cache is usually divided into 4 implementation levels; L1, L2, and L3. The lower the level, the faster and less capacity it will have. Each of these levels is intended to store a type of information according to its frequency of use and its importance. For example, the L1 cache of typical 2020 processors (such as the Intel Core i7-10700K) is only 64 KB per core and has a typical speed of over 1100 GBps and latencies of less than 1 ns. When we get to the L3 cache of this same processor we find a size of 16 MB (shared by all the cores) and a speed of about 200 GBps with latencies of more than 10 ns. The CPU L2 cache would be in between these two.
In this way, the CPU cache is divided into levels and the information stored by each of them will depend on their importance and the frequency with which they are requested. The processor contains a routine that evaluates the last instructions carried out and extrapolates, based on the information obtained in previous instructions, to store data in the cache that will potentially be used by the CPU.
What is the CPU cache for?
The CPU cache is used to speed up the process of searching for data requested by the processor. When the CPU performs an instruction and requests certain data, it must first be fetched from RAM, if not then from storage (SSD or HDD), and after use it will be loaded into RAM. If that same data is required by subsequent instructions, it will start to be stored in the CPU cache, as well as in RAM, since it will be frequently accessed and the cache is quite a bit faster than the best RAM on the market. The most frequent data and instructions are then stored in the various levels of the CPU cache, thus providing very limited but extremely fast storage.
The utility of the CPU cache is basically that, to save frequently accessed data so that they do not have to be searched in other slower storage systems. Then, depending on the level in which it has been saved (L1, L2, L3) they will be used in some areas or others, but they will always be used by the processor. Furthermore, higher levels of the CPU cache may contain copies of lower levels. It may seem counterproductive since the same data is stored in multiple layers and storage is wasted. This is something that depends on the internal structure of the processor and its manufacture (by Intel or AMD), since the highest levels of the CPU cache are usually shared between all cores and thus access to information by the different nuclei can be centralized in some way.
If you are interested in knowing what cache is in a more general way, without resorting to CPU cache, you can take a look at this other definition. Although you should also know that there are other types of cache such as web cache or system cache.