Types of Caches
L1 Cache
The L1 or Level 1 cache is built inside the CPU itself. It holds the most recently accessed data, so when the data is needed again, the CPU checks this cache first instead of going to the main memory or Level 2 cache. This is based on the concept of “Locality of reference,” where data recently accessed by the CPU is likely to be needed again.
L2 Cache
The L2 or Level 2 cache is a separate chip located next to the CPU. It stores recently used data that is not found in the L1 cache. Some CPUs have both L1 and L2 cache built-in and designate the separate cache chip as Level 3 (L3) cache. The cache built into the CPU is faster than a separate cache, and the separate cache is faster than accessing data from RAM. The built-in cache operates at the same speed as the microprocessor.
Disk Cache
The disk cache contains the most recently read data from the hard disk. It is much slower than RAM but helps in speeding up disk read operations.
Instruction Cache vs Data Cache
Instruction cache (I-cache) stores instructions only, while data cache (D-cache) stores only data. Distinguishing between instructions and data helps recognize their different access behavior patterns. Programs often have fewer write accesses and exhibit more temporal and spatial locality compared to the data they process.
Unified Cache vs Split Cache
A unified cache stores both instructions and data, while a split cache consists of two separate units – an instruction cache (I-cache) and a data cache (D-cache). These units can be designed to handle instructions and data independently based on their different characteristics.