• Aucun résultat trouvé

A simple proof of optimality for the MIN cache replacement policy

N/A
N/A
Protected

Academic year: 2021

Partager "A simple proof of optimality for the MIN cache replacement policy"

Copied!
4
0
0

Texte intégral

(1)

HAL Id: hal-01199424

https://hal.inria.fr/hal-01199424

Submitted on 14 Oct 2015

HAL is a multi-disciplinary open access

archive for the deposit and dissemination of

sci-entific research documents, whether they are

pub-lished or not. The documents may come from

teaching and research institutions in France or

abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est

destinée au dépôt et à la diffusion de documents

scientifiques de niveau recherche, publiés ou non,

émanant des établissements d’enseignement et de

recherche français ou étrangers, des laboratoires

publics ou privés.

A simple proof of optimality for the MIN cache

replacement policy

Mun-Kyu Lee, Pierre Michaud, Jeong Seop Sim, Daehun Nyang

To cite this version:

Mun-Kyu Lee, Pierre Michaud, Jeong Seop Sim, Daehun Nyang.

A simple proof of

optimal-ity for the MIN cache replacement policy. Information Processing Letters, Elsevier, 2015, pp.3.

�10.1016/j.ipl.2015.09.004�. �hal-01199424�

(2)

A simple proof of optimality for the MIN cache replacement policy

Mun-Kyu Lee

, Pierre Michaud

, Jeong Seop Sim

, DaeHun Nyang

Abstract

The MIN cache replacement algorithm is an optimal off-line policy to decide which item to evict when a new item should be fetched into a cache. Recently, two short proofs were given by van Roy [B. van Roy, A short proof of optimality for the MIN cache replacement algorithm, Inform. Process. Lett. 102 (2007) 72-73] and Vogler [W. Vogler, Another short proof of optimality for the MIN cache replacement algorithm, Inform. Process. Lett. 106 (2008) 219–220]. We provide a simpler proof based on a novel invariant condition maintained through an incre-mental procedure.

1

Introduction

Let us consider a set Ω of items stored in slower mem-ory and a replacement policy P . We know in advance the sequence of requests ω1, ω2, . . . , ωT from Ω over T time periods, where the size of each item ωiis one data unit (a cache block, a memory page, etc.). The cache capacity is limited and fixed. We assume, without loss of generality, that the cache is initially full. Hence in-serting a new item in the cache requires to evict another item. All the replacement policies start with the same initial cache content. Let CtP ⊂ Ω be the set of items stored in the cache just after ωtis processed by P . If ωt∈ Ct−1P , a hit occurs, and CtP = Ct−1P . Otherwise, a missoccurs, and an item (victim) in Ct−1P should be re-placed by ωt. We denote the victim evicted by policy P at time t as vP

t. Then, CtP = (Ct−1P − {vtP}) ∪ {ωt}. We define vP

t = N U LL for a hit and {N U LL} = ∅. We assume that items cannot be prefetched into the cache, i.e., we consider only demand policies that bring an item into the cache when that item is being requested [2].

The goal of a replacement policy is to minimize the number of misses. The MIN policy achieves this goal by replacing an item in the cache whose next request time is farthest in the future. If an item will not be requested by

Department of Computer and Information Engineering, Inha

Uni-versity, Incheon 402-751, Korea

INRIA, Campus de Beaulieu, 35042 RENNES Cedex, France

time T , its next request time is defined as ∞. If there are multiple items whose next request is at ∞, one of them is randomly selected as a victim. Thus, there may be more than one possibilities of sequence vM IN

1 , . . . , vTM IN for a given request sequence. Without loss of generality, we consider an arbitrary one among them and we call it MIN.

The MIN policy was proposed by Belady [1]. Mattson et al. [2] provided the first proof showing that MIN is an optimal demand policy. However, their proof is long and somewhat complicated. Recently, two short proofs were given by van Roy [3] and Vogler [4] using dynamic programming and amortized simulation techniques, re-spectively. We provide a more intuitive proof using an incremental procedure.

2

Proof of Optimality for MIN

Consider two replacement policies P1 and P2. Given ω1, ω2, . . . , ωT, if vPt1 = v

P2

t for 1 ≤ t ≤ τ − 1 and vP1

τ 6= vPτ2, then D(P1, P2), the deviation point of P1 and P2 is defined as τ . For convenience, we define D(P1, P2) as T + 1 if vPt1 = v

P2

t for 1 ≤ t ≤ T . Let MP

t be the total number of misses generated by P over ω1, ω2, . . . , ωt.

Lemma 1 Given any demand policy P with D(P, M IN ) = τ (1 ≤ τ ≤ T ), it is possible to derive a new demand policyP0 withD(P0, M IN ) > τ which does not generate more misses thanP .

Proof. We design P0so that it imitates P , i.e., vtP0 = vP t , for 1 ≤ t ≤ τ − 1, and vP 0 τ = vM INτ . Then, CP 0 t = CP

t for t ≤ τ − 1. After ωτis processed, CP

0 t = (CtP− {vM IN τ }) ∪ {vτP} for t = τ , and MP 0 τ = MτP. In the case that τ = T , this proves the lemma. If τ < T , P0 tries to imitate P again for t > τ . To examine the possibility of this imitation, we define Dt= CtP− CP

0

t and D0t= CtP0− CP

t , and show that if C P t 6= C

P0

t , the following invariants [I1] and [I2] always hold:

[I1] Dt= {vτM IN} and |D0t| = 1. [I2] Either [I2A] D0t= {vPτ} and MP

0

t = MtP 

or

(3)

(a) Cache at time t − 1 (b) Case 1: ωt6∈ D0t−1and ωt6= vMINτ

(c) Case 2: ωt ∈ D0t−1 (d) Case 3: ωt= vMINτ ∈ Dt−1 Figure 1: Change of cache states at time t according to the request of ωt.

[I2B]MP0 t < MtP

 holds.

Note that once the condition CtP = CP

0

t is satisfied, then P0 can follow exactly P thereafter and CP

u = CP

0

u for any u > t. We also see that [I1] and [I2A] (and thus [I2]) initially hold at t = τ . Now we conduct a proof by induction on t. We consider the following three cases according to ωt(see Figure 1):

Case 1 (ωt6∈ D0t−1and ωt6= vMINτ ): If ωt∈ Ct−1P , then ωt ∈ CP

0

t−1. No replacement occurs both in Ct−1P and CP0

t−1, and the number of misses does not change for P and P0, i.e., MtP = Mt−1P and MP

0

t = MP

0

t−1. Because Dt= Dt−1and D0t= Dt−10 , the invariants [I1] and [I2] hold. If ωt 6∈ Ct−1P , then ωt 6∈ CP

0

t−1 because ωt6∈ Dt−10 and all the elements in CP

0

t−1− Dt−10 are also in Ct−1P (See Figure 1(a).). There are two possibilities according to the choice of P . If P evicts x 6= vM INτ , P0 also evicts x. Then, because D

t = Dt−1, D0t = Dt−10 , MtP = Mt−1P + 1 and MP 0 t = MP 0 t−1+ 1, the invariants [I1] and [I2] hold. If P evicts vτM IN, P0evicts the element in Dt−10 , resulting in CP0

t = CtP. Thereafter, P0follows P , guaranteeing that MuP0 ≤ MP

u for u ≥ t. Case 2 (ωt∈ D0t−1): This is a hit for P0and a miss for P . Therefore, invariant [I2B] holds for t. If P evicts

vτM IN, then CtP0 = CtP. If P evicts x 6= vM INτ , invari-ant [I1] holds with D0t= {x}.

Case 3 (ωt= vMINτ ∈ Dt−1): This case causes a hit for P and a miss for P0. Then, P0 replaces the item in Dt−10 with ωt and follows P thereafter. If [I2B] held at time t − 1, then MP0

u ≤ MuP for u ≥ t. On the other hand, if [I2A] held at time t − 1, then MP0

t could be greater than MP

t . However, we prove that the lat-ter is not possible. To prove this by contradiction, let us assume that [I2A] holds at time t − 1, which implies that only Cases 1 occurred up to time t − 1. Because CuP 6= CP 0 u for any u (τ ≤ u ≤ t − 1) by Ct−1P 6= CP 0 t−1, we see that Dt−1 = Dt−2 = · · · = Dτ = {vτM IN} and Dt−10 = Dt−20 = · · · = D0τ = {vτP}. On the other hand, because at time τ , P0has selected a victim whose next request time was farthest in the future, vPτ must have been requested at some time u (τ < u ≤ t − 1) before Case 3 happens. This implies that Case 2 happened at time u because ωu ∈ D0u−1, which contradicts the

as-sumption. 

Theorem 1 For any demand policy P , MTM IN ≤ MP T. Proof. By repeatedly applying the derivation proce-dure in Lemma 1 until τ = T , we can incrementally

(4)

transform P into M IN without increasing the number

of misses. 

Acknowledgement

This work was supported in part by the National Re-search Foundation of Korea (NRF) grant funded by MOE, Korea (grant number: 2014R1A1A2058514) and MSIP, Korea (grant number: 2014R1A2A1A11050337) and in part by Inha University Research Grant.

References

[1] L. A. Belady. A study of replacement algorithms for a virtual-storage computer. IBM Systems Journal, 5(2):78–101, 1966.

[2] R. L. Mattson, J. Gecsei, D. R. Slutz, and I. L. Traiger. Evaluation techniques for storage hierar-chies. IBM Systems Journal, 9(2):78–117, 1970. [3] B. van Roy. A short proof of optimality for the MIN

cache replacement algorithm. Information Process-ing Letters, 102:72–73, 2007.

[4] W. Vogler. Another short proof of optimality for the MIN cache replacement algorithm. Information Pro-cessing Letters, 106:219–220, 2008.

Figure

Figure 1: Change of cache states at time t according to the request of ω t .

Références

Documents relatifs

Retrouve les objets dans l’image et

Retrouve les objets dans l’image et

Retrouve les objets dans l’image et

In this paper we propose MadCache, a single-threaded and multithreaded adaptive insertion policy that uses Program Counter (PC) behavior history to determine the appropriate

If, e.g., the requirement is to have an RRC uniq of at least 11 for all get operations in the network with 5000 nodes and with high churn (Figure 4), a k value of 40 is sufficient..

On the basis of reuse history from both the original cache tag and the memory access map, the MAIP estimates reuse possibility of the incoming line in terms of two metrics: (1)

Our score normal- ization is based on the factors of query response time, energy spent on mobile device, and monetary cost to be paid to a cloud provider.. We then demonstrate

Indeed, if we consider random traces (items have equal probability to be referenced), all online replacement policies yield the same average hit ratio, equal to the cache size