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).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

The levels

From fastest, smallest and most expensive per byte, to slowest, largest and cheapest:

LevelTypical sizeNotes
CPU registersBytesInside the CPU; used directly by instructions
Level 1 cacheTens of KiB per coreOn each core; often split into instruction and data caches
Level 2 cacheHundreds of KiB to a few MiBUsually per core; larger and slower than L1
Level 3 cacheSeveral MiB to tens of MiBShared by all cores
Main memory (RAM)GiBVolatile; holds programs and data in use
Secondary storageHundreds of GiB to TiBNon-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.

  1. More L3 cache can hold more of the program's frequently used instructions and data.
  2. More requests are hits in cache rather than misses that go to RAM.
  3. 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.

Key idea: Registers, L1, L2, L3, RAM, secondary storage: each level down is larger, slower and cheaper per byte. Check fast levels first; copy items up on a miss.

Check yourself

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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%.

  7. 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.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.