liveBook · Manning

Cache line

As explained in High Performance Unity Game Development

A cache line is a contiguous chunk of memory data transferred into a processor cache as a unit.

A cache line is a contiguous block of memory that the CPU retrieves into cache as a unit. It includes nearby data, so placing values used together close together can let one retrieval supply several values. section 1.2.3

Figure 1.8 Data is retrieved from main memory in chunks called cache lines. When we ask for data that is not already cached, the CPU retrieves the cache line containing that data. Because the cache line also contains nearby data, the CPU brings those values into the cache at the same time.

The figure shows how a request brings the containing block—and nearby values—into the cache together. section 1.2.3

Cache-line size depends on the CPU. The examples assume 64 bytes; cited devices range from 32 bytes on a Pixel 4a to 128 bytes on an M2 MacBook Pro. Lines cover fixed, aligned memory ranges. section 1.2.4

Moving enemies

Moving a survival-game enemy uses its position, direction, and velocity. If those values sit next to each other in memory, retrieving one cache line can bring all three into cache together. section 1.2.4

How High Performance Unity Game Development covers it

How deep it goes
Defines cache lines, gives CPU-dependent sizes, and illustrates alignment; notes that the exact cache-hierarchy path depends on the processor.
Examples
Uses enemy position, direction, and velocity, alongside an assumed 64-byte line and device-specific size examples.
What you can do after
Understand how keeping related enemy fields nearby can let one cache-line retrieval supply several values.
How it connects
Connects cache lines to CPU caches, the memory hierarchy, and data locality.

Also explained in

Compare how 5 books explain cache line →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of High Performance Unity Game Development. The section links point to the parts of the book it draws on.