Knowledgebase

Memory Systems and Caching Print

  • specialisedtechnology, specialised, caching, performance, guide, howto, solution, zillionkinghost
  • 0

Where the time actually goes.

WHAT CACHE IS

Small fast memory holding recently and likely-used data.

WHAT LOCALITY MEANS

Temporal: recently used data is likely used again

Spatial: data near recently used data is likely used

WHY IT MATTERS

Cache design assumes both, and programs violating them perform badly.

WHAT A CACHE LINE IS

The unit transferred, typically several dozen bytes.

WHAT THAT MEANS

Accessing one byte fetches its neighbours.

WHAT SEQUENTIAL ACCESS ACHIEVES

Every fetched line fully used.

WHAT RANDOM ACCESS ACHIEVES

Most of each fetched line wasted.

WHAT THE PERFORMANCE DIFFERENCE IS

Substantial, frequently an order of magnitude.

WHAT FALSE SHARING IS

Threads writing different variables that share a cache line.

WHY IT IS DAMAGING

The line moves between processors constantly, destroying performance with no apparent cause.

WHAT VIRTUAL MEMORY PROVIDES

Each process its own address space, mapped to physical memory.

WHAT PAGE FAULTS ARE

Accessing memory not currently resident, requiring it to be fetched.

WHAT SWAPPING CAUSES

Catastrophic slowdown, because storage is orders of magnitude slower than memory.

WHAT TO MEASURE

Cache misses, not only instruction counts.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot