| The cache on your CPU has become a very | | | | and so gets taken off the shelf and put into a |
| important part of today's computing. The cache is a | | | | bookcase behind the desk. The bookcase is still closer |
| very high speed and very expensive piece of | | | | than the rest of the library and still quick to get to. Now |
| memory, which is used to speed up the memory | | | | when the next person come in asking for Lord of the |
| retrieval process. Due to its expensive CPU's come | | | | Rings, the librarian will firstly look on the shelf and see |
| with a relatively small amount of cache compared with | | | | that the book isn't there. They will then proceed to the |
| the main system memory. Budget CPU's have even | | | | bookcase to see if the book is in there. This is the |
| less cache, this is the main way that the top processor | | | | same for CPU's. They check the L1 cache first and |
| manufacturers take the cost out of their budget | | | | then check the L2 cache for the data they require.Is |
| CPU's.How does the CPU Cache work?Without the | | | | more Cache always better?The answer is mostly yes |
| cache memory every time the CPU requested data it | | | | but certainly not always. The main problem with having |
| would send a request to the main memory which | | | | too much cache memory is that the CPU will always |
| would then be sent back across the memory bus to | | | | check the cache memory before the main system |
| the CPU. This is a slow process in computing terms. | | | | memory. Looking at our library again as an example. If |
| The idea of the cache is that this extremely fast | | | | 20 different people come into the library all after |
| memory would store and data that is frequently | | | | different books that haven't been taken out in quite a |
| accessed and also if possible the data that is around it. | | | | while but the library has been busy before and so the |
| This is to achieve the quickest possible response time | | | | shelf and the bookcase are both full we have a |
| to the CPU. Its based on playing the percentages. If a | | | | problem. Each time a person asks for a book the |
| certain piece of data has been requested 5 times | | | | librarian will check the shelf and then check the |
| before, its likely that this specific piece of data will be | | | | bookcase before realising that the book has to be in |
| required again and so is stored in the cache | | | | the main library. The librarian each time then trots off |
| memory.Lets take a library as an example o how | | | | to get the book from the library. If this library had a non |
| caching works. Imagine a large library but with only one | | | | cache system it would actually be quicker in this |
| librarian (the standard one CPU setup). The first person | | | | instance because the librarian would go straight to the |
| comes into the library and asks for Lord of the Rings. | | | | book in the main library instead of checking the shelf |
| The librarian goes off follows the path to the | | | | and the bookcase.As the fact that non cache |
| bookshelves (Memory Bus) retrieves the book and | | | | systems only work in certain circumstances and so in |
| gives it to the person. The book is returned to the | | | | certain applications CPU's are definitely better with a |
| library once its finished with. Now without cache the | | | | decent amount of cache. Applications such as MPEG |
| book would be returned to the shelf. When the next | | | | encoders are not good cache users because they |
| person arrives and asks for Lord of the Rings, the | | | | have a constant stream of completely different |
| same process happens and takes the same amount | | | | data.Does cache only store frequently accessed |
| of time.If this library had a cache system then once the | | | | data?If the cache memory has space it will store data |
| book was returned it would have been put on a shelf | | | | that is close to that of the frequently accessed data. |
| at the librarians desk. This way once the second | | | | Looking back again to our library. If the first person of |
| person comes in and asks for Lord of the Rings, the | | | | the day comes into the library and takes out Lord of |
| librarian only has to reach down to the shelf and | | | | the Rings, the intelligent librarian may well place Lord of |
| retrieve the book. This significantly reduces the time it | | | | the Rings part II on the shelf. In this case when the |
| takes to retrieve the book. Back to computing this is | | | | person brings back the book, there is a good chance |
| the same idea, the data in the cache is retrieved much | | | | that they will ask for Lord of the Rings part II. As this |
| quicker. The computer uses its logic to determine | | | | will happen more times than not. It was well worth the |
| which data is the most frequently accessed and | | | | Librarian going to fetch the second part of the book in |
| keeps them books on the shelf so to speak.That is a | | | | case it was required.Cache Hit and Cache MissCache |
| one level cache system which is used in most hard | | | | hit and cache miss are just simple terms for the |
| drives and other components. CPU's however use a 2 | | | | accuracy of what goes into the CPU's cache. If the |
| level cache system. The principles are the same. The | | | | CPU accesses its cache looking for data it will either |
| level 1 cache is the fastest and smallest memory, level | | | | find it or it wont. If the CPU finds what's its after that's |
| 2 cache is larger and slightly slower but still smaller and | | | | called a cache hit. If it has to go to main memory to |
| faster than the main memory. Going back to the library, | | | | find it then that is called a cache miss. The percentage |
| when Lord of the Rings is returned this time it will be | | | | of hits from the overall cache requests is called the hit |
| stored on the shelf. This time the library gets busy and | | | | rate. You will be wanting to get this as high as possible |
| lots of other books are returned and the shelf soon fills | | | | for best performance. |
| up. Lord of the Rings hasn't been taken out for a while | | | | |