Cache Memory in Computers - What is Cache Memory?
Cache Pronunciation
It is pronounced same as cash, as in /kash/. Some pronounce it as /kake/ and /cashay/; however, the correct pronunciation is /kash/.
What is Cache in Computers?
You have heard the term cache used in a computer's speed and performance topics. So, what's a cache? As we use our computers, data is generated from the applications and other user interactions and stored in the cache for faster access. This is where the concept of speed comes in.
Cache memory (also referred to as CPU Cache memory) is embedded inside the CPU (Level 1 Cache) or in a chip placed closer to the CPU (Level 2 Cache). There are also Disk Cache and GPU cache. The CPU cache is the fastest - Level 1 Cache followed by Level 2 cache.
How CPU Cache Works
When a set of instructions are executed by the CPU, it first checks for the data in the memory cache. When it is found, the CPU loads the data on itself from processing. When no data is found in the cache, the CPU checks in the RAM. When the data is found in the RAM it is retrieved for processing. If no data is found in the RAM, the CPU finally checks in the secondary storage, including the HDD and the SSD. This makes the cache the fastest storage in a computer.
L1, L2, L3 CPU Cache Architectures
Since it's fast, why is it not used as the main storage space for all computer data? First, the storage space for cache memory is very limited. A modern CPU has about 4-32kb (kilobytes) of space in its L1 cache depending on the CPU architecture. The L2 cache is bigger and tied to the CPU cores. Each modern CPU core has about 512KB of storage space. L3 cache has about 4-8MB in modern CPUs. This limitation is not only tied to speed but also cost. Therefore, caching is left to the most-accessed data while the rest is left to RAM for speed and secondary storage for space.