OCR H446, section 1.1.1 (c)
Three design features have a big effect on how quickly a CPU runs programs. You need to explain how each one helps, and where it stops helping.
Clock speed
The clock produces a regular stream of pulses, and every step the processor takes is timed by them. The clock speed is the number of cycles per second, measured in hertz. A 3.2 GHz processor has 3.2 billion cycles per second.
- Each stage of the fetch-decode-execute cycle takes at least one clock cycle, so a faster clock lets the processor carry out more instructions per second.
- Higher clock speed gives better performance, if everything else stays the same.
Limits of raising clock speed:
- A faster clock produces more heat, and uses more power, so the processor needs better cooling.
- Overclocking (running faster than designed) can make the processor unstable and shorten its life.
- It doesn't help if the processor is waiting for slower memory.
- There are physical limits to how fast signals can travel across a chip.
Number of cores
A core is a complete processing unit, with its own ALU, control unit and registers. A multicore processor has two or more cores on a single chip.
- Each core can run its own instructions at the same time, so the processor can do several jobs in parallel.
- It helps when you run several programs at once, with each one given its own core.
- A single program can be made faster if it is written to split its work into parts that run on different cores.
Limits:
- A program written to run one step after another can't use the extra cores, so it doesn't get faster.
- Some parts of a task must be done in order, which limits the gain.
- The cores must share memory and coordinate, which takes time and can cause delays.
- So doubling the cores doesn't double the speed.
Cache
Cache is a small amount of very fast memory between the processor and main memory (RAM). It holds copies of the instructions and data that were used recently or are likely to be needed soon.
- RAM is much slower than the processor. Without a cache, the CPU would often wait for data.
- When the processor needs something, it checks the cache first.
- If it is there, that's a cache hit, and the data is available almost at once.
- If not, it's a cache miss. The data is fetched from RAM, and a copy is kept in the cache for next time.
- It works because programs show locality: they tend to reuse the same data and instructions (in loops), and to use items that are close together in memory.
Levels of cache
| Level | Size | Speed | Where |
|---|---|---|---|
| L1 | Smallest (tens of KB) | Fastest | Inside each core |
| L2 | Larger (hundreds of KB to a few MB) | Fast | Per core, or shared by a few |
| L3 | Largest of the three (several MB or more) | Slower than L1 and L2, still much faster than RAM | Shared by all cores |
More cache means a higher chance of a hit, so better performance, but cache is expensive and takes up space on the chip. Making it too large can also make it slightly slower to search.
The effect of cache on speed
Suppose the cache takes 2 ns to read, RAM takes 60 ns, and 90% of accesses are hits. A simple estimate of the average access time is
Without a cache, every access would take 60 ns. The cache makes the average about 8 times faster. If the hit rate rose to 98%, the average would fall to ns.
Summary
| Factor | How it improves performance | Limitation |
|---|---|---|
| Clock speed | More cycles, so more instructions, per second | Heat and power use |
| Number of cores | Several instructions run at the same time | Software must be able to use them |
| Cache | Cuts the time spent waiting for RAM | Small and expensive |
Worked example
Task: a user complains that their computer is slow when editing videos. It has a quad-core processor with a small cache. Explain how the three factors affect it.
- Cores: video editing software can split the work (for example, encoding different parts of the video at the same time), so more cores would help a lot, if the software supports it.
- Clock speed: a higher clock would help every instruction, but a faster chip also gets hotter, so the gain is limited.
- Cache: video processing uses large amounts of data, so a larger cache would reduce the time spent fetching from RAM. If the data doesn't fit, the processor still waits for RAM, which is a bottleneck.
Exam tip: don't just say "faster". Say why: more cycles per second, more instructions running at the same time, or less waiting for slow memory. Always mention a limit too, such as heat, software that can't use extra cores, or the cost of cache.
Check yourself
What does clock speed measure?
The number of clock cycles per second, which sets how many steps the processor can carry out each second.
Why does doubling the number of cores not double the speed?
Some programs run one step at a time and can't use extra cores, some parts must be done in order, and the cores need time to coordinate and share memory.
What is a cache hit?
When the data the processor needs is already in the cache, so it can be read without waiting for main memory.
Give one disadvantage of a larger cache
It is more expensive and uses more space on the chip.