Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1And in Conclusion…\dots

Replacement policies:

Table 1:Comparison of cache replacement policies.

FeatureLRUFIFORandom
DescriptionReplace the entry that has not been used for the longest timeReplace the oldest block in the set (queue)Replace a random block
ImplementationBit counters for each cache block; see quick checkFIFO queue or similar approximationFlip a figurative hardware coin
AdvantageTemporal localityReasonable approximation to LRUEasy to implement
DisadvantageComplicated hardware to keep track of access history–Terrible if workload leverages high temporal locality

Write policies:

Table 2:Comparison of cache write policies.

FeatureWrite-throughWrite-back
DescriptionWrite to the cache and memory at the same timeWrite to the cache. Only write back to memory when the block is replaced.
ImplementationEasyMore complicated
“Synchronized” with memory?[6]YesNo. Sometimes cache will have the most current copy of data.
Optimization–Include a dirty bit to only write back modified blocks.
Hit time for writesEach write to a cache block also requires a write to memory. Longer.Multiple writes within a cache block require only one write to memory (the latter happens only on replacement). Faster.
Miss penalty“Read” misses are fast and never result in a write to memory. Shorter.A “read” miss has variable time, since a write to memory may also be needed if the block to be replaced is dirty. Longer on average.
AMATLongerShorter

2Textbook Readings

P&H 5.1-5.4, 5.8, 5.9, 5.13

3Additional References

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

4Exercises

Check your knowledge!

4.1Short Exercises