28
Minimizing Cache Usage in Paging Alejandro López-Ortiz , Alejandro Salinger University of Waterloo

Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Embed Size (px)

Citation preview

Page 1: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Minimizing Cache Usage in PagingAlejandro López-Ortiz , Alejandro SalingerUniversity of Waterloo

Page 2: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Outline

• Paging • Paging with cache usage• Interval Scheduling• Online algorithms• Simulations• Conclusions

2

Page 3: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Paging

3

Slow memory Cache of size k

…p6 p3 p2 p4 p4 p2 p10 p11 p5 p4…Page requests

Is pi in the cache? -Yes

Goal: minimize number of faults

Traditional cost modelHit: 0Fault: 1

Hit-No Fault

Fetch pi from slow memory, evict one page from cache

Page 4: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Paging

Common eviction policies:• Least Recently Used (LRU)• First In First Out (FIFO)• Flush When Full (FWF)• Furthest In The Future (FITF) (offline)

Marking and conservative algorithms are k-competitive

4

Page 5: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Paging with Cache Usage

5

Page 6: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Paging with Cache Usage• Input: sequence , cache size k• Cost: faults + amount of cache used• k(i): number of pages in cache at request i• Cache usage: • Total cost

Goal: minimize total cost

fault cost cell cost

6

Page 7: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Applications• Shared cache multiprocessors

7

Page 8: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Applications• Shared cache multiprocessors• Cooperative caching

8

Page 9: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Applications• Energy efficient caching• Content Addressable Memories (CAMs)

1

14

5

3

8

7

13

9

11

10

15

24

4

18

21

30

17

22

19

2

Cache

3

9

Page 10: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Applications• Energy efficient caching• Content Addressable Memories (CAMs)• Power of search proportional to valid cells

1 5

3

8

7 9 10

15

24

4

30 22 2

Cache

3

10

Page 11: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Related Cost Models• Full Access Cost [Torng 98]• Hit: 1• Fault:• Coincides with classic model when • Marking algorithms, competitive ratio = • Captures locality of reference

11

Page 12: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Related Cost Models• Buying Cache Model [Csirik et al. 01]• Algorithm may purchase cache at cost c(x)• Cost = faults + purchased cache• No limit on purchased cache• No returns

12

Page 13: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Paging as Interval Scheduling

13

Page 14: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Interval Scheduling1 2 3 4 1 1 3 5 2 3 4 5 1 21 2 3 4 1 1 3 5 2 3 4 5 1 2

: feasible schedule of on k-1 machines

can be served with cache size k faults = cache usage =

14

𝐼 (𝜎 )

Page 15: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Offline Optimum

• Reduce to Weighted Interval Scheduling

• Optimal does not schedule an interval with • Remove all such intervals

• ,

• Max weight schedule = minimum total cost

• time (with [Arkin and Silverberg 87])

15

1 2 3 4 1 1 3 5 2 3 4 5 1 2

Page 16: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Online Algorithms

16

Page 17: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Online Algorithms• Marking or conservative algorithms are still k-competitive• But they use all available cache

• Family of cost sensitive algorithms

Let be any paging algorithm : • Keep each page for at most d requests• If necessary, evict page according to A’s eviction policy

17

Page 18: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Online Algorithms

• A is marking or conservative• What is a good choice for d?

• Set d =

• ?

p p

OPT

p p

OPT

Not quite…

18

Page 19: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Competitive Ratio of

• For any conservative or marking A

𝐶𝑅 (𝐴𝛼 )≤ { 2−1

𝛼+1,𝛼<𝑘

¿min(𝑘 , 𝛼 (𝑘+1 )𝑘+𝛼−1 ) ,𝛼≥𝑘

k = 10

19

𝐶𝑅 (𝐴𝛼 )≥ { 2− 1𝛼+1

,𝛼<𝑘−1

¿𝛼 𝑘+𝑘2/2𝛼+𝑘2

,𝛼≥𝑘−1

Page 20: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

20

Case

Competitive Ratio of (upper bound)

Page 21: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Competitive Ratio of (upper bound)

21

Case

max2 , ,𝑘𝛼 (𝑘+1 )𝑘+𝛼−1≤min❑

Page 22: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Locality of Reference• L = Average length of phase in k-phase partition

𝐶𝑅 (𝐴𝛼 )≤ {2𝐿>𝑘𝛼 (𝛼−2)

1+𝑘 (𝛼−1 )+1𝛼+𝑘−1+𝐿

k = 10L = 150

22

Page 23: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Simulations

23

Page 24: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Cost Ratio k=5

24

Page 25: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Cost Ratio k=7

25

Page 26: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Faults

26

Page 27: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Average Cache Usage

27

Page 28: Minimizing Cache Usage in Paging Alejandro López-Ortiz, Alejandro Salinger University of Waterloo

Conclusions• Introduced Minimum Cache Usage problem• Cost-sensitive family of online algorithms • 2 ≤ CR(α) ≤ k• 2-competitive for sequences with high locality

• Polynomial time optimal offline algorithm• Algorithms are competitive in practice

• Future Work:• Deeper lower bound analysis• Other online algorithms• Applications, e.g., shared cache cooperative strategy

Thank you28