Little's Law, Latency and Throughput
If things arrive at rate and each one stays for time , then on average of them are inside at any moment. For a memory system that means bandwidth × latency bytes have to be in flight at once, which tells you how many requests a processor must keep outstanding to use its memory's full speed.
What the symbols mean
- Number in the system
The average number of items inside at any moment (requests in flight, customers in a store).
- Throughput
The average rate at which items arrive and leave (requests per ns, bytes per s).
- Latency
The average time one item spends inside.
What the symbols mean
- Outstanding requests
How many requests must be in flight at once.
- Bandwidth
Bytes per second the memory can deliver.
- Request size
Bytes per request, usually one cache line (64 bytes).
Explanation
Little's law is simply a rule that connects three numbers for anything that flows through a system: how fast things come in (, the throughput), how long each one stays (, the latency) and how many are inside at once (). It says . If 2 customers walk into a coffee shop per minute and each stays 10 minutes, there are about 20 people inside. That's the entire law, and it's named after John Little, who proved it in 1961. The surprising part is how little it assumes.
Why it's true. Watch a system for a long time and draw a graph of , the number of items inside at each moment. The area under that graph counts "item-seconds": each item contributes one unit of height for as long as it's inside, so item adds exactly its stay . Adding up both ways,
Divide both sides by . The left side becomes the average number inside, . On the right, if items passed through, write , which is the arrival rate times the average stay . So . Nothing in that argument cares whether arrivals are regular or random (say, with exponential gaps between them), or in what order items leave. Only averages over a long run matter.
Bandwidth × latency = data in flight. Apply it to memory. Data streams out at a bandwidth of bytes per second, and each byte takes seconds from request to arrival. Little's law says bytes are in transit at any moment. Say GB/s and ns:
(Handy fact: 1 GB/s is exactly 1 byte per ns, since the and cancel.)
How many requests to keep the bus busy. Memory moves whole cache lines, typically bytes. To have 2048 bytes in flight, the processor must keep requests outstanding at all times. If the core can only track 10 misses at once, then caps the throughput at
less than a third of what the memory could deliver. The memory isn't slow; the core isn't asking for enough at once. There's an animation further down of requests moving through a memory system.
Pipelines obey it too. A -stage pipeline finishing one instruction per cycle has per cycle and cycles, so instructions are in flight. Same law, different pipe.
A common mistake. It's tempting to think lower latency is the only way to go faster, or that higher bandwidth helps by itself. Throughput is : with a fixed number of requests in flight, doubling latency halves throughput, and more bandwidth is useless unless something keeps more requests outstanding. The other trap is units: multiply GB/s by ns and you get bytes, but GB/s times µs gives kilobytes. Write the units out every time.
See it
Worked examples
A memory system delivers GB/s with a latency of ns, in -byte cache lines. How many requests must be outstanding at once to use the full bandwidth?
- 1
Little's law says the data in flight is throughput times latency: .
A web service handles requests per second, and each request spends an average of ms inside the service. On average, how many requests are being worked on at once?
- 1
Identify the pieces: the throughput is requests/s and the latency is ms.
Practice
Type your answer and check it. Solve them all to complete the lesson.
A web server handles requests per second, and each takes s on average. How many requests are in progress at once, on average?
A disk queue holds requests on average and completes requests per second. What is the average time a request spends in the queue, in milliseconds?
A memory system delivers GB/s with ns latency, in -byte lines. How many requests must be in flight to use the full bandwidth?
A processor core can track at most outstanding cache misses. Each brings a -byte line, and memory latency is ns. What is the most bandwidth this core can draw, in GB/s? Give 3 decimal places.
A 6-stage pipeline has a ns clock and finishes one instruction per cycle. Each instruction spends ns inside. What is the throughput, in billions of instructions per second?
Requests that miss the last-level cache go either to a nearby memory bank ( of them, ns) or a far one (, ns). The program needs GB/s of -byte lines. On average, how many requests must be in flight?
A system keeps memory busy at full bandwidth. Then the memory latency doubles while the bandwidth stays the same. What has to happen to keep the bandwidth fully used?
The hardest one here. Get it, and you've got this lesson.
A GPU has GB/s of memory bandwidth and ns memory latency. Each group of threads (a warp) repeats a loop: it issues one -byte memory request, waits for it to return, then computes for ns before issuing the next. The GPU has processors (SMs) sharing the load evenly. How many warps does each SM need, at minimum, to keep memory fully busy? Give a whole number.
Where it's used
Little's law sizes almost everything that queues: the number of miss buffers a CPU core needs, how many threads a GPU keeps resident to hide memory latency, how many connections a database pool needs, and how many servers a website needs for a given traffic and response time. Network engineers call the bandwidth-delay product and use it to size buffers and transfer windows for long links.