File tree 1 file changed +8
-0
lines changed
src/simulator/cache/algorithms
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class Mode(Enum):
13
13
FETCH_SIZE = auto ()
14
14
ADD_FETCH_SIZE = auto ()
15
15
NO_COST = auto ()
16
+ CONSTANT = auto ()
16
17
17
18
@classmethod
18
19
def from_str (cls , val : str ) -> 'Mode' :
@@ -26,6 +27,8 @@ def from_str(cls, val: str) -> 'Mode':
26
27
return cls .ADD_FETCH_SIZE
27
28
elif val == 'no_cost' :
28
29
return cls .NO_COST
30
+ elif val == 'constant' :
31
+ return cls .CONSTANT
29
32
else :
30
33
raise ValueError (f'Unknown { cls .__name__ } str value { val !r} ' )
31
34
@@ -65,6 +68,9 @@ class Landlord(StateDrivenOnlineProcessor):
65
68
emulates FIFO, but not quite, as the volume credit decreases whenever an
66
69
additional fraction of the file is fetched.
67
70
71
+ CONSTANT - The credit is set to 1.0 on every access. This corresponds to
72
+ the GD-SIZE(1) policy.
73
+
68
74
Landlord is a generalisation of many strategies, including FIFO, LRU,
69
75
GreedyDual and GreedyDual-Size.
70
76
"""
@@ -182,6 +188,8 @@ def _credit(
182
188
return float (total_bytes )
183
189
else :
184
190
return current_credit
191
+ elif mode is Mode .CONSTANT :
192
+ return 1.0
185
193
186
194
raise NotImplementedError
187
195
You can’t perform that action at this time.
0 commit comments