目录 ← 首页
CS61C

Summary

And in Conclusion\dots

Cache Misses

In order to evaluate cache performance and hit rate, especially with determining how effective our current cache configuration is, it is useful to analyze the misses that do occur, and adjust accordingly. Below, we categorize cache misses into two types:

  1. Compulsory: A miss that must occur when you bring in a certain block for the first time, hence “compulsory”. Compulsory misses are cache attempts that would never be a hit regardless of the cache design.
  2. Noncompulsory: A cache miss that occurs after the data has already been brought into the cache and then evicted afterwards. If the miss could have been alleviated via increasing the cache size or associativity, then the miss is considered noncompulsory.

Cache Associativity

Direct-Mapped caches, where each block of memory maps to specifically one slot in our cache, are good for fast searching, simple hardware, and quick replacement, but not so good for spatial locality! This is where we bring associativity into the matter. Associativity is the number of slots a memory block can map to in our cache. Thus, a Fully-Associative cache has the most associativity, meaning one memory block can map to any cache block. Our Direct-Mapped cache, on the other hand, has the least (being only 1-way set associative) because one memory block can only map to a single cache block.

For an N-way set associative cache, the following relationships are true:

  • Number of Blocks = 𝑁 × Number of Sets
  • Index bits = log2(Number of sets)

Additional References

Amazing Illustrations by Ketrina (Yim) Thompson: CS Illustrated Cache Handouts

Benchmark references

The data in this section is from Patterson & Hennessy, Computer Organization: A General Approach, Fifth Edition.

  • Miss rate by cache size and associativity is Figure B.8 and is aggregated from data measured on SPEC2000 benchmarks on the Alpha architecture, by Cantin and Hill.1 Block sizes for all caches are 64 bytes.
  • Miss rate by cache size and block size is Figure B.11 is from data measured on the SPEC92 benchmark on a DECstation 5000, by Gee et al.2.

Short Exercises

Footnotes

  1. J.F. Cantin and M.D. Hill [2001]. “Cache PErformance for Selected SPEC CPU2000 Benchmarks.” https://doi.org/10.1145/563519.563522 website Version 2.0.

  2. J.D. Gee, M.D. Hill, D.N. Pnevmatikatos, and A.J. Smith [1993]. “Cache performance of the SPEC92 benchmark suite.” IEEE Micro 13:4 (August), 17-27.https://doi.org/10.1109/40.229711