Professional Documents
Culture Documents
By Paul Rubens,
Posted September 19, 2019
What is cache memory? Learn about cache memory, how it works, and
why cache is needed in a modern computer system.
SHARE
Cache memory plays a key role in computers. In fact, all modern computer
systems, including desktop PCs, servers in corporate data centers, and cloud-
based compute resources, have small amounts of very fast static random
access memory (SRAM) positioned very close to the central processing unit
(CPU). This memory is known as cache memory.
But a CPU works much faster than RAM, so sometimes it can be forced to
wait while instructions or data are read from RAM before it can continue
processing, which reduces the overall performance of the computer system.
This cache memory stores data or instructions that the CPU is likely to use in
the immediate future. Because this prevents the CPU from having to wait, this
is why caching is used to increase read performance.
https://www.enterprisestorageforum.com/storage-hardware/guide-to-cache-memory.html 1/5
8/11/2020 Guide to Cache Memory
That means that the CPU is much less likely to be kept waiting – or wait
times will be dramatically reduced. The result is that a very small amount of
cache memory can result in a signi cant increase in the computer's
performance.
How this is done depends on the cache's write policy. The simplest policy is
known as "write-through": with this policy anything written to the memory
cache is also written to RAM straight away.
In fact, the data or instructions are retrieved from RAM and written to cache
memory, and then sent on to the CPU. The reason for this is that data or
instructions that have been recently used are very likely to be required again
in the near future. So anything that the CPU requests from RAM is always
copied to cache memory.
https://www.enterprisestorageforum.com/storage-hardware/guide-to-cache-memory.html 2/5
8/11/2020 Guide to Cache Memory
This begs the question of what happens if the cache memory is already full.
The answer is that some of the contents of the cache memory has to be
"evicted" to make room for the new information that needs to be written
there.
Since RAM is more expensive (but faster) than secondary storage, disk
caches are smaller than hard drives or SSDs. Since SRAM is more expensive
(but faster) than DRAM, memory caches are smaller than RAM.
Level 1
L1 cache is cache memory that is built into the CPU itself. It runs at the same
clock speed as the CPU. It is the most expensive type of cache memory so its
size is extremely limited. But because it is very fast it is the rst place that a
processor will look for data or instructions that may have been buffered there
from RAM.
In fact, in most modern CPUs, the L1 cache is divided into two parts: a data
section (L1d) and an instruction section (L1i). These hold data and
instructions, respectively.
https://www.enterprisestorageforum.com/storage-hardware/guide-to-cache-memory.html 3/5
8/11/2020 Guide to Cache Memory
A modern CPU may have a cache size on the order of 32 KB of L1i and L1d
per core.
Level 2
L2 cache may also be located in the CPU chip, although not as close to the
core as L1 cache. Or more rarely, it may be located on a separate chip close
SHARE
to the CPU. L2 caches are less expensive and larger than L1 caches, so L2
cache sizes tend to be larger, and may be of the order of 256 KB per core.
Level 3
Level 3 cache tends to be much larger than either L1 or L2 cache, but it also
different in another important way. Whereas L1 and L2 caches are private to
each core of a processor, L3 tends to be a shared cache that is common to
all the cores. This allows it to play an important role in data sharing and inter-
core communication. L3 cache may be of the order of 2 MB per core.
Cache Mapping
Cache memory, as has been discussed, is extremely fast – meaning that it
can be read from very quickly.
But there is a potential bottleneck: before data can be read from cache
memory, it has to be found. The processor knows the RAM memory address
of the data or instruction that it wants to read. It has to search the memory
cache to see if there is a reference to that RAM memory address in the
memory cache, along with the associated data or instruction.
There are a number of ways that data or instructions from RAM can be
mapped into memory cache, and these have direct implications for the speed
at which they can be found. But there is a trade-off: minimizing the search
time also minimizes the likelihood of a cache hit, while maximizing the
chances of a cache hit maximizes the likely search time.
Direct Mapping
With direct mapped cache, there is only one place in cache memory that a
given block of data from RAM can be stored.
This means that the CPU only has to look in one place in the memory cache
to see if the data or instructions that it is looking for are present, and if it is it
will be found very quickly. The drawback with direct mapped cache is that it
severely limits what data or instructions can be stored in the memory cache,
so cache hits are rare.
Associative Mapping
Also known as fully associated mapping, this is the opposite of direct
mapping. With an associative mapping scheme, any block of data or
instructions from RAM can be placed in any cache memory block. That
means that the CPU has to search the entire cache memory to see if it
contains what it is looking for, but the chances of a cache hit are much
higher.
Set-Associative Mapping
A compromise between the two types of mapping is set associative mapping,
which allows a block of RAM to be mapped to a limited number of different
memory cache blocks.
https://www.enterprisestorageforum.com/storage-hardware/guide-to-cache-memory.html 4/5
8/11/2020 Guide to Cache Memory
SEE ALL
STO R A G E
HARDWARE
Join the discussion! A RT I C L E S
An eWEEK Property
TERMS OF SERVICE PRIVACY NOTICE CONTACT US ADVERTISE SITEMAP ABOUT US CALIFORNIA – DO NOT SELL MY INFO
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This
compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not
include all companies or all types of products available in the marketplace.
https://www.enterprisestorageforum.com/storage-hardware/guide-to-cache-memory.html 5/5