You are on page 1of 4

alighale hban.

co m

http://alighalehban.co m/co mptia-lesso n-2-whats-l1l2l3-cache/

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

What is the CPU Cache? T he cache on your CPU has become a very important part of todays computing. T he cache is a very high speed and very expensive piece of memory, which is used to speed up the memory retrieval process. Due to its expensive CPUs come with a relatively small amount of cache compared with the main system memory. Budget CPUs have even less cache, this is the main way that the top processor manuf acturers take the cost out of their budget CPUs. 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. T his is a slow process in computing terms. T he idea of the cache is that this extremely f ast memory would store and data that is f requently accessed and also if possible the data that is around it. T his is to achieve the quickest possible 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 stored in the cache memory.

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). T he f irst person comes into the library and asks f or Lord of the Rings. T he librarian goes of f f ollows the path to the bookshelves (Memory Bus) retrieves the book and gives it to the person. T he book is returned to the library once its f inished with. Now without cache the book would be returned to the 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 on a shelf at the librarians desk. T his way once the second person comes in and asks f or Lord of the Rings, the librarian only has to reach down to the shelf and retrieve the book. T his signif icantly reduces the time it takes to retrieve the book. Back to computing this is the same idea, the data in the cache is retrieved much quicker. T he computer uses its logic to determine which data is the most f requently accessed and keeps them books on the shelf so to speak. T hat is a one level cache system which is used in most hard drives and other components. CPUs however use a 2 level cache system and the most modern CPUs use a 3 level on die system. T he principles are the same however, T he level 1 cache is the f astest 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 slightly slower again. Going back to the library, when Lord of the Rings is returned this time it will be stored on the shelf . T his time the library gets busy and lots of other books are returned and the shelf soon f ills up. Lord of the Rings hasnt been taken out f or a while and so gets taken of f the shelf and put into a bookcase behind the desk. T he bookcase is still closer than the rest of the library and still quick to get to. Now when the next person come in asking f or Lord of the Rings, the librarian will f irstly look on the shelf and see that the book isnt there. T hey will then proceed to the bookcase to see if the book is in there. T his is the same f or CPUs. T hey check the L1 cache f irst and then check the L2 cache f or the data they require. Is more Cache always better? T he answer is mostly yes but certainly not always. T he main problem with having too much cache memory is that the CPU will always check the cache memory bef ore the main system memory. Looking at our library again as an example. If 20 dif f erent people come into the library all af ter dif f erent books that havent been taken out in quite a while but the library has been busy bef ore and so the shelf and the bookcase are both f ull we have a problem. Each time a person asks f or a book the librarian will check the shelf and then check the bookcase bef ore realising that the book has to be in the main library. T he librarian each time then trots 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 straight to the book in the main library instead of checking the shelf and the bookcase. As the f act that non cache systems only work in certain circumstances and so in certain applications CPUs 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 stream of completely dif f erent data. In mainstream computing though the benef its of a cache system completely outweigh that of a non-cache system and so is pretty much always used. Does cache only store frequently accessed data? If the cache memory has space it will store data that is close to that of the f requently accessed data. Looking back again to our library. If the f irst person of 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 of the Rings part II. As this will happen more times than not. It was well worth the Librarian going to f etch the second part of the book in case it was required. Cache Hit and Cache Miss

Cache hit and cache miss are just simple terms f or the accuracy of what goes into the CPUs cache. If the CPU accesses its cache looking f or data it will either f ind it or it wont. If the CPU f inds whats its af ter thats called a cache hit. If it has to go to main memory to f ind it then that is called a cache miss. T he 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 f or best perf ormance. L1 Cache L1 cache, which stands f or Level 1 cache, is a type of small and f ast memory that is built into the central processing 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 most 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 is designed 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 slower 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 both program data and instructions. L3 Cache L3, or Level 3, cache is a memory cache that is built into the motherboard. It is used to f eed the L2 cache, and is typically f aster than the systems main memory, but still slower than the L2 cache.

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

You might also like