Inferensys

Glossary

Cache Miss

A cache miss is a hardware event where a processor requests data that is not present in its cache, forcing a slower access to a lower level of the memory hierarchy and degrading performance.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
MEMORY HIERARCHY MANAGEMENT

What is a Cache Miss?

A cache miss is a fundamental performance event in computer architecture where requested data is not found in a fast cache, triggering a costly fetch from a slower, lower level of the memory hierarchy.

A cache miss occurs when a processor or accelerator, such as a Neural Processing Unit (NPU), requests data that is not present in its high-speed cache memory. This forces the system to access a slower, lower level of the memory hierarchy, like main memory (DRAM) or High Bandwidth Memory (HBM), incurring a significant latency penalty. The frequency of cache misses is a primary determinant of overall system performance, as the processor stalls while waiting for data.

Cache misses are categorized by cause. A compulsory miss (or cold miss) happens on the first access to a block of data. A capacity miss occurs when the working set exceeds the cache size, evicting needed data. A conflict miss arises in set-associative caches when multiple memory blocks map to the same cache set. Effective memory hierarchy management relies on optimizing memory access patterns and leveraging prefetching to minimize these misses and mitigate the memory wall.

PERFORMANCE ANALYSIS

Key Characteristics of Cache Misses

A cache miss is not a singular event but a category with distinct types, causes, and measurable impacts on system performance. Understanding these characteristics is essential for optimizing memory hierarchy management in NPUs and other accelerators.

01

The Three Fundamental Miss Types

Cache misses are formally categorized by their underlying cause, which dictates the optimization strategy.

  • Compulsory Miss (Cold Miss): The first access to a block of data that has never been in the cache. This is unavoidable without infinite cache size or perfect prefetching.
  • Capacity Miss: Occurs when the working set of the program is larger than the cache capacity, forcing eviction of blocks that will be needed again.
  • Conflict Miss: Happens in set-associative or direct-mapped caches when multiple memory blocks map to the same cache set, causing thrashing even if the cache has sufficient total capacity.
02

Performance Impact: The Miss Penalty

The miss penalty is the critical metric quantifying a cache miss's cost. It is the additional time required to service the miss versus a hit.

  • Measured in Cycles: The penalty is the number of processor clock cycles stalled waiting for data from the next memory level (e.g., L2 cache, DRAM).
  • Hierarchical: Penalties escalate dramatically down the memory hierarchy (e.g., L1 miss to L2: ~10 cycles; L3 miss to DRAM: ~200+ cycles).
  • Bandwidth Saturation: A high miss rate can saturate the memory bus, increasing the effective penalty for all subsequent misses.
03

Measuring Miss Rates

The miss rate is the primary statistic for cache performance analysis, calculated as Misses / Total Accesses.

  • Absolute vs. Relative: A low absolute rate (e.g., 1%) can still cause severe slowdowns if the program executes billions of memory accesses.
  • MPKI: Misses Per Kilo-Instruction is often a more stable metric than a percentage rate, as it is independent of the total number of cache accesses.
  • Profiling Tools: Hardware performance counters (e.g., via perf on Linux or VTune) are used to precisely measure cache misses during execution.
04

Spatial vs. Temporal Locality Violations

Cache misses directly result from poor exploitation of the two core locality principles.

  • Temporal Locality Miss: Data was accessed, evicted, and then accessed again before it could be reused. This indicates a working set larger than cache or poor replacement policy.
  • Spatial Locality Miss: Data is accessed with a large, unpredictable stride (e.g., random access), wasting the fetched cache line where only a single byte is used. Optimizing data structures for unit stride access is key.
05

Coherence Misses in Multi-Core Systems

In systems with multiple processors or NPU cores sharing memory, coherence misses add a fourth category.

  • Invalidation Miss: Occurs when a cache line is invalidated because another core wrote to it (a write to a shared line). The core must then fetch the updated data.
  • False Sharing: A major cause of artificial coherence misses. Threads on different cores modify different variables that happen to reside on the same cache line, triggering unnecessary invalidations and reloads.
06

Mitigation Strategies

Addressing cache misses involves hardware and software techniques.

  • Hardware: Larger caches, higher associativity, smarter prefetchers, and victim caches.
  • Software (Most Critical):
    • Data Structure Optimization: Align and pack data to fit cache lines.
    • Loop Transformations: Tiling/blocking to fit working sets into cache.
    • Prefetching Intrinsics: Software-initiated prefetch instructions.
    • Memory Access Pattern: Designing algorithms for sequential, predictable access. For NPUs, compiler-driven kernel fusion and scratchpad memory management are essential software mitigations.

How a Cache Miss Works: The Memory Hierarchy

A cache miss is a fundamental performance event in computer architecture where requested data is not found in a processor's fast cache, triggering a costly fetch from a slower, lower level of the memory hierarchy.

A cache miss occurs when a processor core requests data or an instruction that is not present in its local cache memory. This forces the memory controller to retrieve the required cache line from a slower, higher-capacity level, such as main memory (DRAM) or another core's cache in a shared system. The resulting stall introduces significant latency, directly degrading instruction throughput and overall system performance. This event is a primary target for optimization in high-performance computing and AI accelerator design.

The memory hierarchy—comprising registers, L1/L2/L3 caches, main memory, and storage—exists to mitigate the memory wall by exploiting locality of reference. Temporal locality (reuse of data) and spatial locality (access to nearby data) are key principles that make caches effective. When a program's memory access pattern exhibits poor locality, it causes frequent cache misses, overwhelming the available memory bandwidth and becoming a critical bottleneck, especially for data-intensive workloads like neural network inference on NPUs.

CLASSIFICATION

Types of Cache Misses (The 3 C's Model)

The 3 C's model categorizes cache misses based on their underlying cause, which is essential for diagnosing and optimizing memory access patterns in NPU and CPU systems.

Miss TypePrimary CauseTypical MitigationImpact on NPU Performance

Compulsory Miss (Cold Miss)

First access to a block of data; the block has never been in the cache.

Prefetching (hardware or software), larger block sizes.

High impact during initial data loading phases; unavoidable for new data.

Capacity Miss

The working set of the program exceeds the total size of the cache.

Increase cache size, improve data locality, restructure algorithms to use smaller working sets.

Dominant cause of misses when processing large tensors or models that don't fit in cache.

Conflict Miss (Collision Miss)

Multiple memory blocks map to the same cache set/line, causing evictions even when the cache is not full.

Increase cache associativity, use software techniques like array padding or blocking to change memory address mapping.

Significant impact with low-associativity caches; can cause erratic performance drops.

Coherence Miss (Invalidation Miss)

In a multi-core/processor system, a cache line is invalidated due to a write by another processor to maintain coherence.

Optimize data partitioning to minimize shared writes, use synchronization primitives effectively.

Critical in multi-NPU or heterogeneous (NPU/CPU) systems; causes cache line flushes and stalls.

True Sharing Miss

Subset of coherence miss where different processors legitimately read and write the same variable.

Minimize shared mutable data, use thread-local storage, apply fine-grained locking.

Directly increases synchronization overhead and limits parallel scaling.

False Sharing Miss

Processors access different variables that happen to reside on the same cache line, causing unnecessary invalidations.

Align and pad data structures to cache line boundaries, reorganize data layout.

A silent performance killer; wastes bandwidth and increases latency without functional need.

MEMORY HIERARCHY MANAGEMENT

Cache Misses in AI & NPU Contexts

A cache miss occurs when requested data is not found in a fast cache, forcing a slower access to main memory. In AI accelerators, this is a primary bottleneck for performance and energy efficiency.

01

The Core Definition & Performance Impact

A cache miss is a failed attempt by a processor to read or write data in a cache, requiring a fetch from a lower, slower level of the memory hierarchy. This event incurs a performance penalty measured in hundreds of processor cycles. In AI workloads, frequent cache misses can stall the massive parallel compute units in an NPU, drastically reducing throughput and increasing energy consumption per operation. The goal of memory hierarchy optimization is to minimize the miss rate.

02

Types of Cache Misses

Cache misses are categorized by their cause, guiding optimization strategies:

  • Compulsory Miss (Cold Miss): The first access to a memory block. Unavoidable but can be mitigated via prefetching.
  • Capacity Miss: Occurs because the working set is larger than the cache size. Solved by algorithmic tiling or using larger caches.
  • Conflict Miss: Happens in set-associative caches when multiple memory blocks map to the same cache set, evicting each other. Addressed by improving data layout or increasing associativity.
  • Coherence Miss (Invalidation Miss): In multi-core systems, a cache line is invalidated due to a write by another processor. Critical in NUMA systems and for cache coherence protocols.
03

NPU-Specific Memory Architecture

NPUs often employ a multi-tiered, software-managed memory hierarchy distinct from CPU caches. A typical structure includes:

  • Global Memory (HBM/DRAM): High-capacity, high-bandwidth, but high-latency. Source of data on a miss.
  • Shared Memory / Local SRAM: A fast, on-chip, software-managed scratchpad memory. Programmers explicitly control data movement here to avoid hardware cache misses.
  • Register Files: The fastest storage, directly feeding the compute units. Optimization involves data staging: proactively moving data from global to shared memory before computation, mimicking perfect cache behavior.
04

AI Workload Patterns & Miss Causes

Neural network execution exhibits specific patterns that challenge caches:

  • Large Parameter Tensors: Model weights often exceed cache capacity, leading to capacity misses during layer execution.
  • Strided Access Patterns: Convolution operations access input data with large, non-unit strides, harming spatial locality and causing misses.
  • Activation Recomputation: Training frameworks may recompute activations to save memory, causing repeated compulsory misses.
  • Small Batch Sizes: Inference with batch size 1 provides less data reuse per weight load, increasing miss rates compared to large-batch training.
05

Optimization Techniques

Reducing cache misses is a key systems optimization:

  • Loop Tiling/Blocking: Restructures computation to operate on sub-blocks of data that fit in cache, exploiting temporal locality.
  • Data Layout Transformation: Changing the order of tensor dimensions (e.g., NHWC to NCHW) to create contiguous, cache-friendly access patterns.
  • Software Prefetching: Inserting explicit instructions to fetch data into cache or shared memory well before it is needed, hiding latency.
  • Kernel Fusion: Fusing multiple neural network layers into a single kernel avoids writing intermediate results to memory and reading them back, eliminating those cache accesses entirely.
06

Related Concepts & Metrics

Understanding cache misses requires knowledge of adjacent concepts:

  • Miss Penalty: The extra time taken to service a miss.
  • Miss Rate: The fraction of memory accesses that result in a miss.
  • Average Memory Access Time (AMAT): Calculated as: Hit Time + (Miss Rate × Miss Penalty). The key formula for quantifying cache performance.
  • Working Set: The set of memory addresses a program actively uses in a time window. If it exceeds cache size, capacity misses soar.
  • Memory Wall: The growing gap between processor speed and memory latency, making cache miss reduction increasingly critical.
CACHE MISS

Frequently Asked Questions

A cache miss is a fundamental performance event in computer architecture where requested data is not found in a fast cache, forcing a slower access to main memory. This glossary entry addresses common technical questions about its causes, measurement, and mitigation within NPU and AI accelerator contexts.

A cache miss is an event where a processor or accelerator requests data from a cache and the data is not present, forcing a slower, higher-latency access to a lower level of the memory hierarchy, such as main memory (DRAM) or another processor's cache. This is a primary cause of performance degradation and stalled execution in computing systems. The opposite event, where the requested data is found in the cache, is called a cache hit. The performance of a memory subsystem is often measured by its hit rate (the fraction of accesses that are hits) or its miss rate (the fraction that are misses).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.