How does CPU cache work and what are L1, L2 and L3 caches?

Computer processors have developed a lot in recent years. Transistors are getting smaller every year, and advances are reaching a point where Moore’s Law is unnecessary.

When it comes to processors, not only transistors and frequencies are important, but also cache memory.

When talking about CPU (Central Processing Unit) you may have heard about cache memory. However, we don’t pay enough attention to these CPU cache numbers, and they aren’t the main point of CPU ads.

So what exactly is CPU cache and how does it work?

What is CPU cache memory?

Simply put, CPU cache is just a very fast type of memory. In the early days of computing, the speed of processors and the speed of memory were low. However, in the 1980s, processor speeds began to increase rapidly. The system memory (RAM) of the era could not keep up or adapt to the increased speed of processors, so a new type of super-fast memory was born: Processor cache memory.

There are several types of memory in your computer today.

Primary storage, such as a hard drive or SSD, stores most of the data—the operating system and programs.

Next, we have “memory” commonly called RAM. It is much faster than main memory, but is only a short-term storage medium. Your computer and its programs use RAM to store frequently accessed data, which helps make things on your computer smoother and faster.

Finally, there are faster memory units inside the CPU, known as the CPU memory cache.

The memory of the computer is prioritized according to the working speed. The CPU cache is at the top of this hierarchy, being the fastest. It is also closest to where central processing takes place because it is part of the central processing unit itself. According to Tech Target, “cache operates 10 to 100 times faster than RAM, requiring only nanoseconds to respond to CPU demand. »

Computer memory also comes in different types.

Cache memory is a form of static RAM (SRAM), while conventional system RAM is known as dynamic RAM (DRAM). Static RAM can store data without needing to be constantly refreshed like DRAM, making SRAM ideal for cache memory.

The programs and programs on your computer are designed as a set of instructions that the CPU interprets and executes. When you run a program, instructions move from main memory (your hard drive) to the CPU. This is where the memory hierarchy comes into play.

Data is first loaded into RAM and then sent to the CPU. CPUs are capable of executing a large number of instructions per second. To use its full power, the CPU needs access to super-fast memory, and that’s where the CPU cache comes in.

The memory controller fetches data from RAM and sends it to the CPU cache. Depending on your CPU, the controller is either on the CPU or on your motherboard’s Northbridge chipset.

The memory cache then moves data back and forth within the CPU. A memory hierarchy is also present in the CPU cache.

CPU cache levels: L1, L2 and L3

The processor’s cache memory is divided into three “levels”: L1, L2, and L3. Memory hierarchy is again a function of speed and therefore cache size.

So does CPU cache size make a difference in performance?

L1 cache

L1 cache (level 1) is the fastest memory available in a computer system. In terms of access priority, the L1 cache contains the information that the processor needs most to perform a given task.

The size of the L1 cache depends on the processor. Some high-end consumer processors now have 1MB of L1 cache, such as the Intel i9-9980XE, but they are very expensive and still in short supply. Some server chipsets, such as Intel’s Xeon line, also have 1-2MB of L1 memory.

There is no “standard” L1 cache size, so you should check the processor specifications to determine the exact L1 cache size before purchasing.

The L1 cache is generally divided into two parts: the instruction cache and the data cache. The instruction cache deals with the information about the operation that the processor needs to perform, while the data cache contains the data that the operation needs to perform.

L2 cache

L2 cache (level 2) is slower than L1 cache, but larger in size. While L1 cache can be measured in kilobytes, modern L2 cache memory is measured in megabytes. For example, AMD’s highly rated Ryzen 5 5600X has 384KB of L1 cache and 3MB of L2 cache (plus 32MB of L3 cache).

The size of the L2 cache varies by processor, but is generally between 256 KB and 32 MB. Most modern processors have an L2 cache of more than 256 KB, and this size is now considered low. Also, some of the most powerful modern processors have larger L2 caches, more than 8 MB. For example,

When it comes to speed, the L2 cache lags behind the L1 cache, but is still significantly faster than your system’s RAM. L1 cache is typically 100 times faster than RAM, and L2 cache is about 25 times faster.

L3 cache

Let’s go to the L3 cache (level 3). Originally, L3 memory was on the motherboard. That was a long time ago, when most CPUs were only single-core processors. CPU L3 cache today can be large, with high-end mainstream CPUs boasting up to 32MB of L3 cache, while AMD’s new Ryzen 7 5800X3D CPUs have 96MB of L3 cache. Some server processors’ L3 caches may exceed this number. 128 MB.

The L3 cache is the largest unit of cache memory, but also the slowest. Modern processors include L3 cache in the processor itself. But while the L1 and L2 caches exist for each core on the chip itself, the L3 cache is more like a common memory pool that the entire chip can use.

The images below show CPU memory memory levels for an Intel Core i5-3570K CPU released in 2012 and an AMD Ryzen 5800X CPU released eight years later in 2020. The CPU cache information is located in the lower right corner of the second image.

z cpu cache tab
Information about amd ryzen 5800x cpuz cache

Notice how the L1 cache is split in half while the L2 and L3 caches are larger on both processors, respectively? However, the AMD Ryzen 5800X has five times more L3 cache than the Intel i5-3570K.

How much CPU cache do I need?

It’s a good question. Much better as you would expect. The latest processors will naturally have more cache memory than previous generations, as well as potentially faster cache memory. One thing you can do is learn how to compare processors effectively. There is a lot of information out there, and learning how to compare and contrast different processors can help you make the right buying decision.

Cache memory design is constantly changing, especially as memory becomes cheaper, faster, and denser. For example, one of AMD’s latest innovations is Intelligent Access Memory and Infinity Cache, both of which boost performance.

The big question: How does CPU cache work?

In the most basic terms, data flows from RAM to L3 cache, then L2, and finally L1. When a processor looks for data to perform an operation, it first tries to find it in the L1 cache. If the processor finds it, the condition is called a cache hit. It then proceeds to search L2 and then L3.

If the processor cannot find data in one of the memory caches, it tries to access it from your system memory (RAM). When this happens, it’s called a cache miss.

As we know, cache is designed to speed up data flow between main memory and CPU. The time it takes to retrieve data from memory is called “latency”.

L1 cache is the fastest and closest to the core and has the lowest latency, while L3 has the highest latency. When there is a shortage of cache memory, cache latency increases because the processor must fetch data from system memory.

Latency continues to decrease as computers become faster and more efficient. Low-latency DDR4 and DDR5 RAM and ultra-fast solid-state drives reduce latency and make your entire system faster than ever. In this case, the memory speed of your system is also important.

Explanation of CPU Cache Speed

The size and speed of the CPU cache are important to the overall performance of your computer. As with most computer hardware issues, more is better, and faster is always the smartest choice.

However, you shouldn’t let CPU cache be the final deciding factor when it comes to buying a new CPU. Of course, more and faster is better, but you can vary the number of cores, CPU clock speed, etc. you should also consider other important CPU performance factors such as

Leave a Reply

Your email address will not be published. Required fields are marked *