Top Banner
alighalehban.com http://alighalehban.com/comptia-lesson-2-whats-l1l2l3-cache/ CompTIA A+ Lesson 2 – Under s t anding Cpu Cache , L1,L2,L3 Cache What is the CPU Cache? T he cache on yo ur CPU has become a very import ant part of to day’ s computing. The cache is a very high speed and very expensive pi ece of mem or y , whic h is used t o s peed up the me mory retr ieval pro cess . Due to its expensive CP U’s come with a relat ively small am ount of cache compa red with t he main sys tem me mory. Budget CPU’s have even l ess cache, this is t he main way that t he to p processor manufact urers t ake the cost out of their budget CPU’ s. How does t he CPU Cache work? Without the cache memory every time the CPU requested data it would send a request to the main memory whi ch would then be sent back across the mem ory bus to the CPU. This is a s low process in computing terms. T he i dea of the cache is that this extremel y f ast memory would st ore and data that is f requen tly access ed and also if pos sible the data that is around it. This is to achi eve the quic kest po ss ibl e response time to the CPU. I ts based on playing the percentages. I f a certain pi ece of data has been requested 5 times bef ore, its lik ely that t his specif ic pi ece of data wil l be requ ired ag ain an d so is sto red in the cache memory.
4

alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

Apr 14, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

7/27/2019 alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

http://slidepdf.com/reader/full/alighalehbancom-comptia-alesson-2understanding-cpu-cachel1l2l3cache 1/4

alighalehban.com http://alighalehban.com/comptia-lesson-2-whats-l1l2l3-cache/

CompTIA A+ Lesson 2 – Understanding Cpu Cache , L1,L2,L3

Cache

What is the CPU Cache?

The cache on your CPU has become a very important part of today’s computing. The cache is a very high

speed and very expensive piece of memory, which is used to speed up the memory retr ieval process. Due to

its expensive CPU’s come with a relat ively small amount of cache compared with the main system memory.

Budget CPU’s have even less cache, this is t he main way that the top processor manufacturers take the

cost out of their budget CPU’s.

How does the CPU Cache work?

Without the cache memory every time the CPU requested data it would send a request to the main memory

which would then be sent back across the memory bus to the CPU. This is a s low process in computing

terms. The idea of the cache is that this extremely fast memory would store and data that is f requently

accessed and also if possible the data that is around it. This is to achieve the quickest poss ible response

time to the CPU. Its based on playing the percentages. If a certain piece of data has been requested 5

times bef ore, its likely that this specif ic piece of data will be required again and so is sto red in the cache

memory.

Page 2: alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

7/27/2019 alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

http://slidepdf.com/reader/full/alighalehbancom-comptia-alesson-2understanding-cpu-cachel1l2l3cache 2/4

Lets take a library as an example o how caching works. Imagine a large library but with only one librarian (the

standard one CPU setup). The f irst perso n comes into t he library and asks f or Lord of the Rings. The

librarian goes of f f ollows the path to the bookshelves (Memory Bus) retrieves the book and gives it to the

person. The book is returned to t he library once its f inished with. Now without cache the book would be

returned to t he shelf . When the next person arrives and asks f or Lord of the Rings, the same process

happens and takes the same amount of time.

If this library had a cache system then once the book was returned it would have been put o n a shelf at the

librarians desk. This way once the second perso n comes in and asks f or Lord o f the Rings, the librarianonly has to reach down to the shelf and retrieve the book. This signif icantly reduces the t ime it takes to

retrieve the book. Back to computing this is the same idea, the data in the cache is retrieved much quicker.

The computer uses its logic to determine which data is the mos t f requently accessed and keeps them

books on the shelf so t o speak.

That is a one level cache system which is used in mos t hard drives and o ther components . CPU’s however 

use a 2 level cache system and the most modern CPU’s use a 3 level on die system. The principles are the

same however, The level 1 cache is the fastest and smallest memory, level 2 cache is larger and slightly

slower but still smaller and f aster than the main memory, level 3 cache again usually is larger and slight ly

slower again. Going back to the library, when Lord o f the Rings is returned this t ime it will be sto red on t he

shelf . This time the library gets busy and lots of other books are returned and the shelf soon f ills up. Lord

of the Rings hasn’t been taken out f or a while and so gets t aken of f the shelf and put into a bookcase

behind the desk. The bookcase is still closer than the rest of the library and still quick to get to. Now when

the next person come in asking for Lord of the Rings, the librarian will f irstly look on the shelf and see that

the book isn’t there. They will then proceed to the bookcase to see if the book is in there. This is the same

f or CPU’s. They check the L1 cache f irst and then check the L2 cache for the data t hey require.

Is more Cache always better?

The answer is mostly yes but certainly not always. The main problem with having too much cache memory is

that the CPU will always check the cache memory bef ore the main system memory. Loo king at our libraryagain as an example. If 20 dif f erent people come into the library all af ter dif f erent books that haven’t been

taken out in quite a while but the library has been busy before and so the shelf and the bookcase are both

f ull we have a problem. Each time a perso n asks f or a book the librarian will check the shelf and then check

the bookcase before realising that the book has to be in the main library. The librarian each time then trot s

of f to get the book f rom the library. If this library had a non cache system it would actually be quicker in this

instance because the librarian would go st raight to the book in the main library instead of checking the

shelf and the bookcase.

 As the f act that non cache syst ems only work in cert ain circumstances and so in certain applicat ions CPU’s

are def initely better with a decent amount of cache. Applications such as MPEG encoders are not good

cache users because they have a constant s tream of completely dif f erent data. In mainstream computing

though the benef its o f a cache system completely outweigh that of a non-cache system and so is pretty

much always used.

Does cache only store fre quent ly accessed data?

If the cache memory has space it will store data that is close to that o f the f requently accessed data.

Loo king back again to o ur library. If the f irst person o f the day comes into the library and takes out Lord of 

the Rings, the intelligent librarian may well place Lord of the Rings part II on the shelf . In this case when the

person brings back the book, there is a good chance that they will ask f or Lord o f the Rings part II. As this

will happen more t imes than not. It was well worth the Librarian going to f etch the second part of the boo kin case it was required.

Cache Hit and Cache Miss

Page 3: alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

7/27/2019 alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

http://slidepdf.com/reader/full/alighalehbancom-comptia-alesson-2understanding-cpu-cachel1l2l3cache 3/4

Cache hit and cache miss are just s imple terms f or the accuracy of what goes into the CPU’s cache. If the

CPU accesses its cache looking for data it will either f ind it or it wont. If the CPU f inds what’s its af ter 

that ’s called a cache hit. If it has t o go to main memory to f ind it then that is called a cache miss. The

percentage of hits f rom the overall cache requests is called the hit rate. You will be wanting to get this as

high as possible for best performance.

L1 Cache

L1 cache, which stands f or Level 1 cache, is a type of small and fast memory that is built into the centralprocess ing unit. Of ten ref erred to as internal cache or primary cache, it is used to access important and

f requently used data. L1 cache is the f astest and mos t expensive type of cache that is built into the

computer.

You can check your computer cache info with WMIC CPU command in CMD .

L2 Cache

L2, or Level 2, cache is used to store recently accessed inf ormation. Also known as secondary cache, it isdesigned to reduce the time needed to access data in cases where data has already been accessed

previously. L2 cache can also reduce data access time by buf f ering the data that processor is about to

request f rom memory, as well as program instructions. L2 cache is secondary to the CPU and is s lower than

L1 cache, despite of ten being much larger. In addition, data that is requested f rom L2 cache is copied to L1

cache. Requested data is removed f rom L2 cache if it is an exclusive cache, and stays there if it is an

inclusive cache. L2 cache is most of ten unif ied, which means that it is used to store bo th program data and

instructions.

L3 Cache

L3, or Level 3, cache is a memory cache that is built into t he motherboard. It is used to f eed the L2 cache,

and is typically f aster than the system’s main memory, but st ill slower than the L2 cache.

This was a brief review , IF you like to learn more about cpu cache Click Here

Page 4: alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

7/27/2019 alighalehban.com-CompTIA A+Lesson 2_Understanding Cpu Cache_L1L2L3_Cache

http://slidepdf.com/reader/full/alighalehbancom-comptia-alesson-2understanding-cpu-cachel1l2l3cache 4/4