All subjects · Computer Science · WCP01 Principles of Computer Science
The memory hierarchy: registers, cache, main memory and storage
Edexcel IAL Computer Science · WCP01 Principles of Computer Science
Fast memory is expensive and small; cheap memory is slow and large. Computers combine several levels so that the data in use is usually in a fast level (spec point 1.1.6).
The levels
From fastest, smallest and most expensive per byte, to slowest, largest and cheapest:
| Level | Typical size | Notes |
|---|---|---|
| CPU registers | Bytes | Inside the CPU; used directly by instructions |
| Level 1 cache | Tens of KiB per core | On each core; often split into instruction and data caches |
| Level 2 cache | Hundreds of KiB to a few MiB | Usually per core; larger and slower than L1 |
| Level 3 cache | Several MiB to tens of MiB | Shared by all cores |
| Main memory (RAM) | GiB | Volatile; holds programs and data in use |
| Secondary storage | Hundreds of GiB to TiB | Non-volatile (SSD, hard disk); holds data long term |
Typical sizes vary between processors; the order is what matters.
How it operates
When the CPU needs an item it checks the fastest level first. If the item is there (a hit) it is used straight away. If not (a miss), the next level down is checked, and a copy is brought up into the faster levels so that it will be close next time.
This works because programs tend to reuse the same items (loops, frequently called functions) and to use items stored near each other (arrays, sequential instructions).
Benefits and drawbacks
Benefits: performance close to that of the fastest memory, at a cost close to that of the cheapest; large non-volatile capacity.
Drawbacks: misses cost extra time; keeping copies in different levels consistent adds complexity; cache is costly and takes up space on the chip; a hierarchy only helps if data is reused.
Worked example
Explain why a computer with more level 3 cache may run a program faster even though RAM speed is unchanged.
- More L3 cache can hold more of the program's frequently used instructions and data.
- More requests are hits in cache rather than misses that go to RAM.
- Cache is much faster than RAM, so the CPU waits less.
Answer: A larger cache gives a higher hit rate, so fewer slow trips to RAM.
Check yourself
- Which level of the memory hierarchy is fastest?
- CPU registers
- Level 1 cache
- Main memory
- Secondary storage
Show answer
CPU registers. Registers are inside the CPU and accessed directly.
- Which cache level is usually shared by all cores of a multi-core processor?
- Level 1
- Level 0
- Level 3
- Level 2 only on the first core
Show answer
Level 3. L1 (and usually L2) are per core; L3 is shared.
- Which list is in order from smallest capacity to largest?
- Registers, L1 cache, L2 cache, RAM, secondary storage
- L1 cache, registers, RAM, L2 cache, secondary storage
- Secondary storage, RAM, L3 cache, L1 cache, registers
- RAM, registers, L1 cache, secondary storage, L2 cache
Show answer
Registers, L1 cache, L2 cache, RAM, secondary storage. Capacity grows as you move down the hierarchy.
- Explain why computers do not use only the fastest type of memory.
Show answer
The fastest memory is very expensive per byte and physically small, so a large amount would cost too much; a hierarchy gives near top speed at lower cost.. Give the cost or size reason and say what a hierarchy achieves.
- What happens on a cache miss?
- The program stops with an error
- The item is fetched from a slower level and a copy is placed in the cache
- The CPU skips the instruction
- The item is deleted from RAM
Show answer
The item is fetched from a slower level and a copy is placed in the cache. A miss means going further down the hierarchy and bringing the item closer for next time.
- A program makes 200 memory requests and 170 are found in cache. What percentage is the hit rate?
Show answer
85 %. 170 / 200 x 100 = 85%.
- Which level of the hierarchy is non-volatile?
- Level 2 cache
- Secondary storage
- Main memory (RAM)
- CPU registers
Show answer
Secondary storage. Only secondary storage keeps data with the power off.
Sources
Last updated 8 November 2026. Spotted a mistake? Tell us.