How does CPU caching work? What are L1, L2 and L3 caches? (2023)

Readers like you help support MUO. If you make a purchase through links on our site, we may receive an affiliate commission.See more information.

Computer processors have come a long way in recent years. Transistors are getting smaller every year and advancements are reaching a point where Moore's Law is becoming obsolete.

With processors, it's not just transistors and frequencies that count, but cache as well.

You may have heard of cache when talking about CPUs (Central Processing Units). However, we don't pay enough attention to these CPU cache numbers, nor are they the highlight of the CPU commercials.

So how important is the CPU cache and how does it work?

What is CPU cache?

Simply put, a CPU memory cache is just a very fast type of memory. In the early days of computing, processor speeds and memory speeds were slow. However, in the 1980s, processor speeds began to increase rapidly. System memory (RAM) at the time could not handle or keep up with the increasing speeds of the CPU, so a new generation of ultra-fast memory was born: CPU cache.

Your computer now has several types of memory.

There is primary storage, such as a hard drive or SSD, where most of the data is stored: the operating system and programs.

Next we have random access memory,commonly known as RAM🇧🇷 This is much faster than primary storage, but it's only a short-term storage medium. Your computer and the programs on it use RAM to store frequently accessed data, which helps keep actions on your computer nice and fast.

Finally, the CPU has even faster memory units known as the CPU memory cache.

Computer memory has a hierarchy based on its speed of operation. The CPU cache is at the top of this hierarchy and is the fastest. It is also the closest to where the central processing takes place, since it is part of the CPU itself.

(Video) What is Cache Memory? L1, L2, and L3 Cache Memory Explained

Computer memory also comes in different types.

Cache memory is a form of static RAM (SRAM), while normal system RAM is known as dynamic RAM (DRAM). Static RAM can store data without constantly updating it, unlike DRAM, making SRAM ideal for memory caching.

How does CPU caching work?

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

The data is first loaded into RAM and then sent to the CPU. Today's CPUs are capable of executing a large number of instructions per second. To get the most out of its performance, the CPU needs access to ultra-fast memory, which is where the CPU's cache comes into play.

The memory controller takes data from RAM and sends it to the CPU cache. Depending on your CPU, either the controller resides on the CPU or the northbridge chipset resides on your motherboard.

The memory cache then carries out the data exchange within the CPU. The memory hierarchy also exists within the CPU cache.

(Video) CPU Cache Explained - What is Cache Memory?

Related:What is a CPU and what does it do?

The CPU cache levels: L1, L2 and L3

The CPU cache is divided into three "levels": L1, L2, and L3. The memory hierarchy is again based on speed and therefore cache size.

So does the size of the CPU cache make a difference in performance?

Hidden L1

The L1 cache (level 1) is the fastest memory in a computer system. In terms of access priority, the L1 cache contains the data that the CPU is likely to need when performing a specific task.

The size of the L1 cache depends on the CPU. Some high-end consumer CPUs now have a 1MB L1 cache, like the Intel i9-9980XE, but they cost a lot of money and are still rare. Some server chipsets, such as Intel's Xeon series, also have a 1 to 2 MB L1 memory cache.

There is no "standard" L1 cache size, so you should check the CPU specs to determine the exact memory L1 cache size before purchasing.

How does CPU caching work? What are L1, L2 and L3 caches? (1)

The L1 cache is normally divided into two sections: the instruction cache and the data cache. The instruction cache contains the information about the operation to be performed by the CPU, while the data cache contains the data on which the operation will be performed.

Hidden L2

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

The size of the L2 cache varies depending on the CPU, but is generally between 256KB and 8MB. Most modern CPUs have more than 256KB of L2 cache, and that size is now considered small. Also, some of the most powerful modern CPUs have a larger L2 memory cache of more than 8 MB.

(Video) Hardware L1, L2, and L3 Cache

When it comes to speed, L2 cache lags behind L1 cache, but is still much faster than system RAM. L1 memory cache is typically 100 times faster than your RAM, while L2 cache is around 25 times faster.

Hidden L3

In the L3 cache (level 3). In the early days, the L3 memory cache actually resided on the motherboard. That was a long time ago when most CPUs were just single core processors. Now, the L3 cache on your CPU can be huge, with high-end consumer CPUs having L3 caches of up to 32MB. Some server CPU L3 caches can exceed this by up to 64MB.

The L3 cache is the largest cache storage unit but also the slowest. Modern CPUs contain the L3 cache within the CPU itself, but while L1 and L2 caches exist for each core on the chip itself, the L3 cache is more of a general-purpose set of memory that the entire chip can handle. wear.

The following image shows the CPU memory cache levels for an Intel Core i5-3570K CPU:

How does CPU caching work? What are L1, L2 and L3 caches? (2)

Notice how the L1 cache is split in two, while L2 and L3 are each larger.

How much CPU cache do I need?

That is a good question. More is better, as you might expect. Of course, newer CPUs contain more CPU cache than previous generations, with potentially faster cache as well. One thing you can do is learnhow to compare cpu effectively🇧🇷 There is a lot of information out there, and learning how to compare and contrast different CPUs can help you make the right buying decision.

https://www.anrdoezrs.net/links/7251228/type/dlg/sid/UUmuoUeUpU36509/https://www.youtube.com/supported_browsers?next_url=https%3A%2F%2Fwww.youtube.com%2Fwatch% 3Fv%3DIA8au8Qr3lo

(Video) L1 L2 L3 Cache

How does data move between CPU memory caches?

The big question: How does the CPU cache work?

Simply put, data flows from RAM to L3 cache, then to L2, and finally to L1. When the processor looks up data to perform an operation, it first tries to find it in the L1 cache. If the CPU finds it, the condition is known as a cache hit. He then proceeds to find it in L2 and then L3.

If the CPU doesn't find the data in any of the memory caches, it tries to access it from system memory (RAM). When this happens, it is called a cache miss.

Well, as we know, the purpose of the cache is to speed up the exchange of information between the main memory and the CPU. The time it takes to access data from memory is called "latency."

L1 cache has the lowest latency as it is the fastest and closest to the core, and L3 has the highest. Memory cache latency increases when a cache miss occurs because the CPU needs to get data from system memory.

Latency continues to drop as computers get faster and more efficient. Low-latency DDR4 RAM and super-fast SSDs reduce latency and make your entire system faster than ever. The speed of the system memory also plays a role here.

The future of CPU cache

Cache design is constantly evolving, especially as memory becomes cheaper, faster, and denser. For example, one of AMD's latest innovations isIntelligent Access Memory and Infinite Cachethat increase the performance of your computer.

(Video) What is CPU Cache?

Videos

1. Cache Memory Explained
(ALL ABOUT ELECTRONICS)
2. 3.2.5 Blocking for the L1, L2, and L3 caches
(LAFF-On Programming for High Performance)
3. L2 vs L3 Cache memory - In Short
(The Wheels and Chips Journal)
4. What is Cache Memory? L1, L2 & L3 Cache Memory Explained!
(RPM Tech Tips)
5. Cache Memory 1: Introduction
(Jacob Schrum)
6. CPU Caches
(Mr Gauvain)
Top Articles
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated: 03/15/2023

Views: 5267

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.