Lec 5
Lec 5
Lecture 5
Block Replacement Techniques & Write Strategy
FIFO policy:
LRU policy:
6 6 3 3 1
3 3 1 1 5
1 1 7 5 2
0 7 5 2 0
7 5 2 0 4
5 2 0 4 7
J
Older 0 F
1 C
1 B
0 X
1 Y
Newer 0 A
1 Z
J J Y X Z BC F A
F
C 011: PLRU Block B
B is here
X
Y 110: MRU block
A is here
Z
A>F Z
Practical Pseudo-LRU
J Refs: J,Y,X,Z,B,C,F,A
Older 0 F
1 C
011: PLRU Block B
1 B is here
0 X
1 Y
110: MRU block
Newer 0 A is here
1 Z
Binary tree encodes PLRU partial order
At each level point to LRU half of subtree
Each access: flip nodes along path to block
Eviction: follow LRU path
Overhead: (a-1)/a bits per block
Not Recently Used (NRU)
Keep NRU state in 1 bit/block
Bit is reset to 0 when installed / re referenced
Bit is set to 1 when it is not referenced and other block in the
same set is referenced
Evictions favor NRU=1 blocks
If all blocks are NRU=0 / 1 then pick by random
Provides some scan and thrash resistance
Randomizing evictions rather than strict LRU order
Re-reference Interval Prediction
RRIP
Extends NRU to multiple bits
Start in the middle
promote on hit
demote over time
Can predict near-immediate, intermediate, and distant re-
reference
Least Frequently Used
Counter per block, incremented on reference
Evictions choose lowest count
Logic not trivial (a2 comparison/sort)
Storage overhead
1 bit per block: same as NRU
How many bits are helpful?
Write strategy
Write through: The information is written to both the block in
the cache and to the block in the next level memory
Write Through: read misses do not need to write back
evicted line contents
Write back: The information is written only to the block in the
cache. The modified cache block is written to main memory
only when it is replaced.
is block clean or dirty?
Write Back: no writes of repeated writes
What About Write Miss?
Write allocate: The block is loaded into cache on a write miss