23
Cache Memory By Sean Hunter

Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Embed Size (px)

Citation preview

Page 1: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Cache Memory

By Sean Hunter

Page 2: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

What is Cache?

“A computer memory with very short access time used for storage of frequently used instructions or data” – webster.com

Page 3: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Types of Cache

L1/L2/L3 Cache RAM Cache Disk Cache Software Level Cache

Page 4: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –
Page 5: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

L1/L2/L3 Cache (Cache Memory)

Cache closer to the CPU that stores recently accessed data from RAM

Holds instructions to be executed next and variables for the CPU

Page 6: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

L2 Cache

COAST: Cache on a Stick

Page 7: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Cache Memory Continued

Level 1 Cache is stored on the CPU L2/L3 Cache stored near, but not on the

CPU L1/L2/L3 Cache is more expensive than

RAM

Page 8: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –
Page 9: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Cache MemoryReplacement Policies

CPU requests data from cached memoryCache memory has data, sends to CPU (Hit)RAM has data, sends to CPU (Miss)

Cache performance measured by hits/misses where the ideal algorithm has a ratio close to 1.

Page 10: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Replacement Policies

On a miss the data from RAM is loaded in to Cache

Due to the nature of most programs (Variables are accessed multiple times in the same program) this cached data will have a high chance of being accessed often.

One possible replacement algorithm is a FIFO based one where the oldest cached data is replaced first.

Page 11: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

CPU Cache - Write Policies

CPU writes data in cache (hit)Write-through – Cache and RAM updatedWrite-back – Cache updated, RAM updated

when new data is going to replace that data in cache

Dirty bit keeps track of if a part of cache has changed

Page 12: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

CPU Cache - Write Policies

CPU writes but data not in cache (Miss)Write-no-allocate – RAM updatedWrite-allocate – RAM updated, data loaded

into cache

Page 13: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

CPU Cache – SMP Problems

Multiprocessor systems have trouble with write-through and write-back IE. One processor updates data cached by

both processorsPossible Solutions:

Cache only unshared memory Update all cache simultaneously

Page 14: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

RAM Cache

Same as Cache Memory or CPU Cache, except instead of the L1/L2 cache caching RAM, RAM caches data from the hard disk.

For example, Windows loads multiple required libraries for running in memory, but code isn’t executed from them constantly.

Page 15: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Disk Cache

Like cache memory, disk cache holds data recently read or written to from a hard disk. This is to speed up subsequent reads from recently accessed data.

Most newer hard drives have around 8mb of cache memory.

Page 16: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –
Page 17: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Software Cache

Software also needs to cache data into RAM that it uses often – however, more often than not, this data isn’t directly from the hard disk.

The data software caches is often processed data from a file translated by the program into another data structure. The process of translating may take a long time, so the cache in RAM is used to speed up the rest of the programs run time.

Page 18: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Software Cache - Example

Games such as Half-Life and Unreal Tournament 2004 have a loading time before each game where the map, models, sounds, and other important data are all loaded into RAM.

Example: Website loading lots of data from an SQL server each page load may take a few seconds, but if the first load caches all the data, the load may only take a few milliseconds.

Page 19: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Software Cache - Example

Internet ExplorerHistory – Keeps a cache of recently viewed

websites for easy accessCache – Keeps images and other files on disk

so websites load faster the second time you visit them. These files are updated when there is a newer version of them on the server, or the cache is cleared.

Page 20: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –
Page 21: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

Interesting Facts

The first Celeron CPU had no caching, however it performed almost as fast as the PII with cache.

Because some chipsets couldn’t cache more than the first 64mb of RAM a rumor was spread that Windows 98 could only use up to 64mb of RAM, however in reality it supports up to 2GB of RAM. In these chipsets, adding more than 64MB of RAM

decreased performance.

Page 22: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

More interesting facts

Some motherboards ship with fake cache memory (Pictures are of fake cache memory) to both deceive the user and to sell cheaper non-cache motherboards without having to manufacture completely different motherboard designs.

Page 23: Cache Memory By Sean Hunter. What is Cache? “A computer memory with very short access time used for storage of frequently used instructions or data” –

References

http://searchstorage.techtarget.com/sDefinition/0,,sid5_gci211730,00.html

http://searchstorage.techtarget.com/sDefinition/0,,sid5_gci211963,00.html

http://www.karbosguide.com/hardware/module3b2.htm http://arstechnica.com/paedia/c/caching/caching-1.html http://www.gb.tomshardware.com/howto/01q1/010212/

socket5-06.html http://www.hardwaresite.net/wb.html http://www.pcwebopedia.com/TERM/D/disk_cache.html