This is not the current version of the class.

Storage 4: Eviction policies and types of file

Overview

In this lecture, we present some eviction policies and anomalies, and discuss different types of file.

Full lecture notes on storageTextbook readings

Motivating multi-slot caches

Multi-slot cache abstraction

1 2 3 4 1 2 5 1 2 3 4 5
A 1 1 4 4 5 5 5 5 5
B 2 2 1 1 1 1 3 3
C 3 3 2 2 2 2 4
FIFO, 3 slots, hit rate 3/12

Associativity

Eviction

Hits and misses

Eviction policies for fully-associative caches

When a slot is needed, evict the slot that:

Eviction policies for fully-associative caches

When a slot is needed, evict the slot that:

Question

The optimal eviction algorithm

When a slot is needed, evict the slot that:

Example

1 2 3 4 1 2 5 1 2 3 4 5
A
B
C
Optimal
1 2 3 4 1 2 5 1 2 3 4 5
A 1 1
B 2 2
C 5
Optimal, 3 slots, hit rate 5/12

When can you predict the future?

More slots means better hit rate!

1 2 3 4 1 2 5 1 2 3 4 5
A 5
B 1
C 2
FIFO, 3 slots, hit rate 3/12
1 2 3 4 1 2 5 1 2 3 4 5
A
B
C
D
FIFO, 4 slots, hit rate ?
1 2 3 4 1 2 5 1 2 3 4 5
A 1
B 2
C
D
FIFO, 4 slots, hit rate 2/12

More slots means better hit rate for LRU

1 2 3 4 1 2 5 1 2 3 4 5
A
B 1
C 2
LRU, 3 slots, hit rate 2/12
1 2 3 4 1 2 5 1 2 3 4 5
A 1 1
B 2 2
C
D
LRU, 4 slots, hit rate 4/12

Eviction and writes

Streams vs. random-access files

Special files

Streams

Write semantics

Memory mapping

Forking, piping, and stdio