The answersDownload the PDF
Worksheet

F9.5 CPU performance

Logic and computer systems · GCSE · OCR J277 1.1.2, AQA 8525 3.4.5 · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Clock speed, cores and cache, measured with models.

Questions 5 marks in all

  1. [1 mark]What does a clock speed of 3 GHz mean?

    1. A3 billion clock pulses each second
    2. B3 million instructions in total
    3. C3 cores
    4. D3 GB of cache
  2. [1 mark]Why might doubling the cores not halve the time a program takes?

    1. ASome of the work cannot be split across cores
    2. BCores share one clock pulse
    3. CMore cores use less cache
    4. DThe operating system can only use one core
  3. [1 mark]Why does more cache usually make a CPU faster?

    1. AMore data is kept in fast memory, so fewer slow trips to RAM are needed
    2. BCache increases the clock speed
    3. CCache adds more cores
    4. DCache stores files when the power is off
  4. [1 mark]A job takes 60 seconds on 1 core and all of it can be split. How many seconds on 4 cores?

  5. [1 mark]What is a drawback of a higher clock speed?

    1. AThe processor gets hotter and uses more power
    2. BIt needs more RAM
    3. CIt makes cache slower
    4. DIt reduces the number of cores

The task: the cache model

Use run_cache(requests, size) on the request list [5, 6, 5, 7, 5, 6, 8, 5, 6, 7], for cache sizes 1 to 6. Print one line for each size in the form size <n>: <hits> hits, then print best size: <n> for the smallest cache that gets the most hits, working it out with a loop.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

def run_cache(requests, size):
    cache = []
    hits = 0
    for address in requests:
        if address in cache:
            hits = hits + 1
            cache.remove(address)
        elif len(cache) == size:
            cache.pop(0)
        cache.append(address)
    return hits, len(requests) - hits

requests = [5, 6, 5, 7, 5, 6, 8, 5, 6, 7]

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/f9-5-cpu-performance/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. With 80% of a job splittable, how many cores does it take to get under 20 seconds for a 60-second job?
  2. Make a request list where a cache of 2 gets no hits at all.
  3. Why does a phone slow its processor down when it gets hot?