Skip to content

Commit 77fe708

Browse files
committed
Remove create_cache
1 parent 7205803 commit 77fe708

4 files changed

Lines changed: 10 additions & 77 deletions

File tree

libCacheSim-python/libcachesim/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Request,
77
__doc__,
88
__version__,
9-
create_cache,
109
open_trace,
1110
process_trace,
1211
process_trace_python_hook,
@@ -44,7 +43,6 @@
4443
"PythonHookCachePolicy",
4544
"__doc__",
4645
"__version__",
47-
"create_cache",
4846
"open_trace",
4947
"process_trace",
5048
"process_trace_python_hook",

libCacheSim-python/libcachesim/__init__.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ libCacheSim Python bindings
77
.. autosummary::
88
:toctree: _generate
99
10-
create_cache
1110
open_trace
1211
ARC_init
1312
Clock_init
@@ -28,14 +27,6 @@ libCacheSim Python bindings
2827

2928
from .const import TraceType
3029

31-
def create_cache(
32-
eviction_algo: str,
33-
cache_size: int,
34-
eviction_params: str,
35-
consider_obj_metadata: bool
36-
) -> Cache: ...
37-
38-
3930
def open_trace(
4031
trace_path: str,
4132
type: TraceType,

libCacheSim-python/src/pylibcachesim.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,6 @@ PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter)
364364
Reader: A new reader instance for the trace.
365365
)pbdoc");
366366

367-
/**
368-
* @brief Generic function to create a cache instance.
369-
*/
370-
m.def(
371-
"create_cache",
372-
[](const std::string& eviction_algo, const uint64_t cache_size,
373-
const std::string& eviction_params,
374-
bool consider_obj_metadata) { return nullptr; },
375-
py::arg("eviction_algo"), py::arg("cache_size"),
376-
py::arg("eviction_params"), py::arg("consider_obj_metadata"),
377-
R"pbdoc(
378-
Create a cache instance.
379-
380-
Args:
381-
eviction_algo (str): Eviction algorithm to use (e.g., "LRU", "FIFO", "Random").
382-
cache_size (int): Size of the cache in bytes.
383-
eviction_params (str): Additional parameters for the eviction algorithm.
384-
consider_obj_metadata (bool): Whether to consider object metadata in eviction decisions.
385-
386-
Returns:
387-
Cache: A new cache instance.
388-
)pbdoc");
389-
390367
/* TODO(haocheng): should we support all parameters in the
391368
* common_cache_params_t? (hash_power, etc.) */
392369

libCacheSim-python/tests/test_eviction.py

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
Sieve,
1313
TinyLFU,
1414
TwoQ,
15-
create_cache,
1615
)
1716
from tests.utils import get_reference_data
1817

1918

2019
@pytest.mark.parametrize("eviction_algo", [
2120
FIFO,
2221
ARC,
23-
# Clock,
24-
# LRU,
25-
# S3FIFO,
26-
# Sieve,
27-
# TinyLFU,
28-
# TwoQ,
22+
Clock,
23+
LRU,
24+
S3FIFO,
25+
Sieve,
26+
TinyLFU,
27+
TwoQ,
2928
])
3029
@pytest.mark.parametrize("cache_size_ratio", [0.01])
3130
def test_eviction_algo(eviction_algo, cache_size_ratio, mock_reader):
@@ -35,7 +34,7 @@ def test_eviction_algo(eviction_algo, cache_size_ratio, mock_reader):
3534
cache = eviction_algo(cache_size=int(mock_reader.get_wss()*cache_size_ratio))
3635
req_count = 0
3736
miss_count = 0
38-
37+
3938
# Limit the number of requests to avoid long test times
4039
# max_requests = 1000
4140
for i, req in enumerate(mock_reader):
@@ -45,50 +44,18 @@ def test_eviction_algo(eviction_algo, cache_size_ratio, mock_reader):
4544
if not hit:
4645
miss_count += 1
4746
req_count += 1
48-
47+
4948
if req_count == 0:
5049
pytest.skip("No requests processed")
51-
50+
5251
miss_ratio = miss_count / req_count
5352
reference_miss_ratio = get_reference_data(eviction_algo.__name__, cache_size_ratio)
5453
if reference_miss_ratio is None:
5554
pytest.skip(f"No reference data for {eviction_algo.__name__} with cache size ratio {cache_size_ratio}")
5655
assert abs(miss_ratio - reference_miss_ratio) < 0.01, f"Miss ratio {miss_ratio} is not close to reference {reference_miss_ratio}"
57-
56+
5857
except Exception as e:
5958
print(f"Error in test_eviction_algo: {e}")
6059
raise
6160
finally:
6261
pass
63-
64-
65-
# @pytest.mark.parametrize("eviction_algo", [
66-
# "FIFO",
67-
# "ARC",
68-
# "Clock",
69-
# "LRU",
70-
# "S3FIFO",
71-
# "Sieve",
72-
# "TinyLFU",
73-
# "TwoQ",
74-
# ])
75-
# @pytest.mark.parametrize("cache_size_ratio", [0.01, 0.1])
76-
# def test_eviction_algo_generic(eviction_algo, cache_size_ratio, mock_reader):
77-
# cache = create_cache(eviction_algo=eviction_algo,
78-
# cache_size=int(mock_reader.get_wss()*cache_size_ratio),
79-
# eviction_params="",
80-
# consider_obj_metadata=False)
81-
# req_count = 0
82-
# miss_count = 0
83-
# for req in mock_reader:
84-
# hit = cache.get(req)
85-
# if not hit:
86-
# miss_count += 1
87-
# req_count += 1
88-
89-
# miss_ratio = miss_count / req_count
90-
# print("Check eviction algo: ", eviction_algo, "with cache size ratio: ", cache_size_ratio)
91-
# reference_miss_ratio = get_reference_data(eviction_algo, cache_size_ratio)
92-
# if reference_miss_ratio is None:
93-
# pytest.skip(f"No reference data for {eviction_algo} with cache size ratio {cache_size_ratio}")
94-
# assert abs(miss_ratio - reference_miss_ratio) < 0.01, f"Miss ratio {miss_ratio} is not close to reference {reference_miss_ratio}"

0 commit comments

Comments
 (0)