-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.pyi
More file actions
248 lines (216 loc) · 7.73 KB
/
__init__.pyi
File metadata and controls
248 lines (216 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
from __future__ import annotations
from typing import bool, int, str, tuple
from collections.abc import Iterator
from .libcachesim_python import ReqOp, TraceType, SamplerType
from .protocols import ReaderProtocol
class Request:
clock_time: int
hv: int
obj_id: int
obj_size: int
ttl: int
op: ReqOp
valid: bool
next_access_vtime: int
def __init__(
self,
obj_size: int = 1,
op: ReqOp = ReqOp.READ,
valid: bool = True,
obj_id: int = 0,
clock_time: int = 0,
hv: int = 0,
next_access_vtime: int = -2,
ttl: int = 0,
): ...
def __init__(self): ...
class CacheObject:
obj_id: int
obj_size: int
class CommonCacheParams:
cache_size: int
default_ttl: int
hashpower: int
consider_obj_metadata: bool
class Cache:
cache_size: int
default_ttl: int
obj_md_size: int
n_req: int
cache_name: str
init_params: CommonCacheParams
def __init__(self, init_params: CommonCacheParams, cache_specific_params: str = ""): ...
def get(self, req: Request) -> bool: ...
def find(self, req: Request, update_cache: bool = True) -> CacheObject: ...
def can_insert(self, req: Request) -> bool: ...
def insert(self, req: Request) -> CacheObject: ...
def need_eviction(self, req: Request) -> bool: ...
def evict(self, req: Request) -> CacheObject: ...
def remove(self, obj_id: int) -> bool: ...
def to_evict(self, req: Request) -> CacheObject: ...
def get_occupied_byte(self) -> int: ...
def get_n_obj(self) -> int: ...
def print_cache(self) -> str: ...
class CacheBase:
"""Base class for all cache implementations"""
def __init__(self, _cache: Cache): ...
def get(self, req: Request) -> bool: ...
def find(self, req: Request, update_cache: bool = True) -> CacheObject: ...
def can_insert(self, req: Request) -> bool: ...
def insert(self, req: Request) -> CacheObject: ...
def need_eviction(self, req: Request) -> bool: ...
def evict(self, req: Request) -> CacheObject: ...
def remove(self, obj_id: int) -> bool: ...
def to_evict(self, req: Request) -> CacheObject: ...
def get_occupied_byte(self) -> int: ...
def get_n_obj(self) -> int: ...
def print_cache(self) -> str: ...
def process_trace(self, reader: ReaderProtocol, start_req: int = 0, max_req: int = -1) -> tuple[float, float]: ...
@property
def cache_size(self) -> int: ...
@property
def cache_name(self) -> str: ...
# Core cache algorithms
class LRU(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class FIFO(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class LFU(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class ARC(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class Clock(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class Random(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
# Advanced algorithms
class S3FIFO(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class Sieve(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class LIRS(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class TwoQ(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class SLRU(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class WTinyLFU(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class LeCaR(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class LFUDA(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class ClockPro(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class Cacheus(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
# Optimal algorithms
class Belady(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
class BeladySize(CacheBase):
def __init__(
self, cache_size: int, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False
): ...
# Plugin cache
class PluginCache(CacheBase):
def __init__(
self,
cache_size: int,
cache_name: str = "PythonHookCache",
default_ttl: int = 25920000,
hashpower: int = 24,
consider_obj_metadata: bool = False,
cache_init_hook=None,
cache_hit_hook=None,
cache_miss_hook=None,
cache_eviction_hook=None,
cache_remove_hook=None,
cache_free_hook=None,
): ...
def set_hooks(self, init_hook, hit_hook, miss_hook, eviction_hook, remove_hook, free_hook=None): ...
# Readers
class TraceReader(ReaderProtocol):
c_reader: bool
def __init__(self, trace: str, trace_type: TraceType = TraceType.UNKNOWN_TRACE, **kwargs): ...
class SyntheticReader(ReaderProtocol):
c_reader: bool
def __init__(
self,
num_of_req: int,
obj_size: int = 4000,
time_span: int = 604800,
start_obj_id: int = 0,
seed: int | None = None,
alpha: float = 1.0,
dist: str = "zipf",
num_objects: int | None = None,
): ...
# Trace generators
def create_zipf_requests(
num_objects: int,
num_requests: int,
alpha: float = 1.0,
obj_size: int = 4000,
time_span: int = 604800,
start_obj_id: int = 0,
seed: int | None = None,
) -> Iterator[Request]: ...
def create_uniform_requests(
num_objects: int,
num_requests: int,
obj_size: int = 4000,
time_span: int = 604800,
start_obj_id: int = 0,
seed: int | None = None,
) -> Iterator[Request]: ...
# Analyzer
class TraceAnalyzer:
def __init__(self, analyzer, reader: ReaderProtocol, output_path: str, analysis_param, analysis_option): ...
def run(self) -> None: ...
def cleanup(self) -> None: ...
# Utilities
class Util:
@staticmethod
def convert_to_oracleGeneral(reader, ofilepath, output_txt: bool = False, remove_size_change: bool = False): ...
@staticmethod
def convert_to_lcs(
reader, ofilepath, output_txt: bool = False, remove_size_change: bool = False, lcs_ver: int = 1
): ...
@staticmethod
def process_trace(
cache: CacheBase, reader: ReaderProtocol, start_req: int = 0, max_req: int = -1
) -> tuple[float, float]: ...