Categories
Technology

What Are the L1 L2 and the L3 Cache?

To understand the L1, L2, and the L3 cache, we first need to grasp what cache memory is, which is often referred to as the CPU cache.

What Is a Cache Memory/CPU Cache?

Plainly put, a cache memory is a component on your computer’s motherboard. (The technical term for the hardware is SRAM). It’s usually either directly integrated into the CPU chip, or placed closer to the processor separately, with a direct-line (the esoteric term is BUS) to your main CPU.

If that sounds confusing, think of the cache as a temporary storage area, that your device can efficiently retrieve data from. Imagine it as buying milk from your neighborhood grocery store versus getting it directly from the manufacturer or the dairy farm. Obviously, buying milk from near your house is much more efficient. The purpose of a cache memory is precisely like that.

Hierarchy of a Computer Memory Hierarchy of a Computer Memory (Based on Speed)

A partial snapshot of a drive information - inside the Windows 10 system information
A partial snapshot of drive information — inside the Windows 10 “System Information.”

Your computer has different types of memory. For your primary storage, you’d have an SSD. This is where your Operating system and other programs are installed.

Then, you’d have RAM, which is much faster than your primary storage. A level-up from it, is where the cache memory comes into the picture. Amongst all 3, cache memory is the fastest.

In other words:

  1. Cache Memory is faster than >
  2. RAM (Random Access Memory), which in turn is faster than >
  3. Your primary storage

How the L1, L2, and the L3 Cache Come Into Play

a screen capture showing the l1, l2, and the l3 cache size
A screen capture showing the l1, l2, and the l3 cache size.

Cache memory has “levels.” And as you may have guessed, they go by L1, L2, and L3. Let’s explore each.

What Is the L1 Cache?

L1 cache is the fastest of all; but, has the least amount of storage/memory/size.

Typically, the L1 cache will store the data that your CPU is most likely to reaccess it. (Think of the milk and the grocery store example I gave at the beginning). Usually, most L1 caches can store anywhere from 128 KB – 256 KB, with modern technology testing the limits with as much as 2 MBs.

The L1 cache is commonly referenced as the primary cache as well.

What Is the L2 Cache?

Larger in size — 256 KB – 512 KB, sometimes greater than 5 MBs — but slower than L1, the L2 cache comes next in line when it comes to data retrieval. In other words, stores data that your CPU will need right after.

Another name for the L2 cache is secondary cache.

What Is the l3 Cache?

Based on the above two, you may have guessed that the L3 cache has the largest size capacity — can start directly in MBs, and go all the way up to a significant size. However, it is the slowest of all 3.

What further makes L3 unique is that it can be shared between all cores, unlike the L1 and L2, which usually are private and dedicated to each core. And due to its shared feature, is also why L3 has the highest capacity as it can store data for all of the cores together.

You May Also Want to Know

What Is a Cache Hit?

A cache hit is an occurrence of a successful data retrieval from the cache memory. In other words, when the system finds the data from the cache, it’s called a hit, exact terminology being cache hit.

What Is a Cache Miss?

Opposite of a hit event, a cache miss occurs when the system cannot find the date from the cache, and is forced to retrieve it from another location (typically, the main memory).

What Is Latency — As It Relates to Cache?

Latency can be defined as the time it takes for the system to fetch the cache’s data. By definition, L1 has the lowest latency, followed by L2 and L3.
In cases of a cache miss, you’d likely have the highest latency because the data needs to be derived from the main memory, or another location outside the cache.

You May Also Want to Check Out:

Conclusion

By now, you must have discerned how important a cache memory is for any computer, and its role in providing us with blazing speeds — that we experience in our regular and everyday computer usage.

Although, as we humans always do, I am confident that we’d be pushing the limits on how much the L1, L2, and L3 cache can store by being innovative, creative, scientific, and methodological in the future iterations of new CPUs.