S4 · Lesson 27 · Memory bandwidth and NUMA
Bandwidth per core, misses in flight, non-uniform memory and the energy of moving data
Core counts have grown faster than the pins that feed them, so a modern server's memory bandwidth, divided among its cores, is a few gigabytes a second each. Getting even that needs enough misses in flight to cover the latency, and in a multi-socket machine half the memory sits behind another processor, slower and narrower. Moving the data also costs more energy than computing with it. This lesson puts those limits into numbers: Little's law for memory, the NUMA penalty, and the energy budget of a byte.
- The curve is the bandwidth a core or chip can sustain with N cache misses in flight, each fetching a 64-byte line from memory L nanoseconds away: , capped by the peak bandwidth.
- Too few outstanding misses leave the memory idle however fast it is; past the knee, more misses only queue.
- The readout is the number of misses in flight needed to reach the peak, from Little's law.
Predict
A chip's memory delivers 100 GB/s with a 90 ns latency, in 64-byte lines. How many misses must be in flight at once to use all of it?
Little's law: data in flight = bandwidth × latency bytes, which is 141 lines of 64 bytes. A core with 10 to 20 miss-status registers can't do that alone; it takes many cores, or prefetchers, all missing at once.
Name it
Bandwidth per core
Peak bandwidth = channels × transfers per second × 8 bytes. A 64-core server with 8 channels of DDR5-4800 has 307 GB/s, under 5 GB/s per core. A program needs about (bytes per instruction) × IPC × clock; data-heavy codes exceed their share and become bandwidth-bound.
Little's law for memory
Each core can track only as many misses as it has miss-status holding registers, so a single core's bandwidth is at most MSHRs × line ÷ latency.
NUMA
In a multi-socket machine each socket has its own memory. A local access might take 90 ns and a remote one, crossing the socket link, 140 ns; with a fraction r of accesses remote, the average is , and the link's bandwidth caps remote traffic. Operating systems allocate pages on the socket of the thread that first touches them (first touch) and can migrate them later.
The energy of data movement
Rough figures for a recent process: a 64-bit floating-point operation costs tens of picojoules; reading 64 bits from a nearby SRAM, about ten; sending a bit a millimeter across the chip, about 0.1 pJ; reading a bit from DDR DRAM, 10 to 20 pJ; from stacked HBM, a few. Fetching an operand from DRAM costs far more energy than using it, which is why caches, blocking and near-memory computing save energy as well as time.
Worked example
A 64-core server has 8 channels of DDR5-4800. What bandwidth does each core get, and is it enough for a core running at 3 GHz and IPC 2 that moves 0.5 bytes per instruction from memory?
Show the solution
- One channel.
- Per core. Eight channels give 307 GB/s in all, so each core gets
- What the core needs. It fits, with little to spare.
- A hungrier program. Two bytes per instruction would need 12 GB/s, and the program would run at the bandwidth's pace instead.
Answer each core gets 4.8 GB/s, enough for the 3 GB/s this core needs, with little to spare.
Worked example
A thread makes 30% of its memory accesses to the other socket, at 140 ns against 90 ns locally. What is its average latency?
Show the solution
- Average latency. which is 17% worse than all-local.
- A common trap. If one thread initialized an array that all threads later use, first touch put the whole array on one socket, and half the threads see the remote latency on every access.
- The fix. Initializing the array in parallel spreads it out.
Answer the average latency is 105 ns, 17% worse than all-local.
Worked example
A kernel reads 1 GB from DDR at 15 pJ per bit and performs floating-point operations at 20 pJ each. Where does the energy go?
Show the solution
- Reading.
- Computing.
- Compare. Moving the data takes six times the energy of the arithmetic; reusing each byte from cache six times would make them equal.
Answer most of the energy goes to moving data: 0.12 J for the reads against 0.02 J for the arithmetic.
Check
A server has 8 memory channels at 3200 MT/s, 8 bytes wide, shared by 96 cores.
(a)
What is its peak bandwidth?
(b)
How much is that per core?
Check
A memory system delivers 200 GB/s at 80 ns latency in 64-byte lines; each core can have 32 misses outstanding.
(a)
How many misses must be in flight to reach full bandwidth?
(b)
What bandwidth can one core sustain?
Check
Local memory takes 80 ns and remote memory 130 ns; a thread makes 0.5 of its accesses remote.
(a)
What is its average latency?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
What fraction of remote accesses keeps the average at 120 ns?
Check
A kernel reads 1 GB from DRAM at 4 pJ per bit and performs 20 × 10⁹ operations at 20 pJ each.
(a)
How much energy does reading take?
Write units the way you normally would: 1.5 J, 1500 mJ and 0.0015 kJ are the same answer.
(b)
How many times the computing energy is that?
Check
One thread allocates and zeroes a large array; then 32 threads on two sockets process it in parallel, and half of them run slowly. What happened, and what fixes it?
Check
Memory delivers bandwidth B (bytes per second) at latency L in lines of S bytes; a core tracks m misses.
Step 1
How many misses must be in flight for full bandwidth?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What bandwidth can one core sustain?
Step 3
How many such cores does it take to saturate the memory?
Check
Write sustained_bw(misses, line, latency_ns, peak_gbs): the bandwidth in GB/s that a given number of misses in flight sustain, capped at the peak; and cores_to_saturate(peak_gbs, latency_ns, line, mshrs): the fewest cores, each with mshrs misses in flight, that reach the peak.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can a single core rarely use a whole chip's memory bandwidth, even when it does nothing but read memory?
By Little's law, the bandwidth a requester sustains equals the amount of data it has in flight divided by the latency. A core can have only as many misses outstanding as it has miss-status holding registers, typically 10 to 20, and each brings one 64-byte line per memory latency of about 100 ns. That's around 10 GB/s, while a server's memory system can deliver several hundred. To use it all, many cores (or aggressive prefetchers that issue requests ahead) must keep enough misses in flight together to cover the latency.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.