理解cache misses & instruction misses& cache locality

刁越
2023-12-01
  • cache

    A CPU cache is a hardware used by the central processing unit (CPU) of a computer to reduce the average cost (time or energy) to access data from the main memory.

    Most CPUs have a hierarchy of multiple cache levels with separate instruction-specific and data-specific caches at level 1.

  • cache miss

    A cache miss is a failed attempt to read or write a piece of data in the cache, which results in a main memory access with much longer latency.

    There are three kinds of cache misses:

    1. instruction read miss
    2. data read miss
    3. data write miss
  • Locality of reference

    Locality of reference (principle of locality) is the tendency of a processor to access the same set of memory locations repetitively over a short period of time.

    There are two basic types of reference locality:

    1. temporal locality

      reuse of specific data and/or resources within a relatively small time duration

    2. spatial locality(data locality)

      The use of data elements within relatively close storage locations

      Sequential locality, a special case of spatial locality means access data linearly.

  • instruction miss

    One of the three type of cache miss.

  • References

  1. What Is a Cache Miss?
  2. How can I cause an instruction cache miss?
  3. Cache locality of an array and amortized complexity
  4. How L1 and L2 CPU Caches Work, and Why They’re an Essential Part of Modern Chips
  5. Why does cache locality matter for array performance?
  6. Confused between Temporal and Spatial locality in real life code
  7. Locality of Reference and Cache Operation in Cache Memory
  8. Impact of Cache Locality
 类似资料: