Skip to content

Commit aa7e27a

Browse files
committed
Clean up all explict DataLoader usage
1 parent 00482c9 commit aa7e27a

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

docs/src/en/getting_started/quickstart.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ With libcachesim installed, you can start cache simulation for some eviction alg
9191

9292
The above example demonstrates the basic workflow of using `libcachesim` for cache simulation:
9393

94-
1. Use `DataLoader` to download a cache trace file from an S3 bucket.
95-
2. Open and efficiently process the trace file with `TraceReader`.
96-
3. Initialize a cache object (here, `S3FIFO`) with a specified cache size (e.g., 1MB).
97-
4. Run the simulation on the entire trace using `process_trace` to obtain object and byte miss ratios.
98-
5. Optionally, process only a portion of the trace by specifying `start_req` and `max_req` for partial simulation.
94+
1. Open and efficiently process the trace file with `TraceReader`.
95+
2. Initialize a cache object (here, `S3FIFO`) with a specified cache size (e.g., 1MB).
96+
3. Run the simulation on the entire trace using `process_trace` to obtain object and byte miss ratios.
97+
4. Optionally, process only a portion of the trace by specifying `start_req` and `max_req` for partial simulation.
9998

10099
This workflow applies to most cache algorithms and trace types, making it easy to get started and customize your experiments.
101100

@@ -108,10 +107,7 @@ Here is an example demonstrating how to use `TraceAnalyzer`.
108107
import libcachesim as lcs
109108

110109
# Step 1: Get one trace from S3 bucket
111-
URI = "cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
112-
dl = lcs.DataLoader()
113-
dl.load(URI)
114-
110+
URI = "s3://cache-datasets/cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
115111
reader = lcs.TraceReader(
116112
trace = dl.get_cache_path(URI),
117113
trace_type = lcs.TraceType.ORACLE_GENERAL_TRACE,
@@ -143,8 +139,7 @@ Here is an example demonstrating how to use `TraceAnalyzer`.
143139

144140
The above code demonstrates how to perform trace analysis using `libcachesim`. The workflow is as follows:
145141

146-
1. Download a trace file from an S3 bucket using `DataLoader`.
147-
2. Open the trace file with `TraceReader`, specifying the trace type and any reader initialization parameters.
142+
1. Open the trace file with `TraceReader`, specifying the trace type and any reader initialization parameters. The URI starting with `s3://`, will download a trace file from an S3 bucket.
148143
3. Configure the analysis options with `AnalysisOption` to enable or disable specific analyses (such as request rate, size, etc.).
149144
4. Optionally, set additional analysis parameters with `AnalysisParam`.
150145
5. Create a `TraceAnalyzer` object with the reader, output directory, and the chosen options and parameters.

examples/plugin_cache/s3fifo.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,16 @@ def cache_free_hook(cache):
193193
cache_name="S3FIFO",
194194
)
195195

196-
URI = "cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
197-
dl = lcs.DataLoader()
198-
dl.load(URI)
196+
URI = "s3://cache-datasets/cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
199197

200-
# Step 2: Open trace and process efficiently
198+
# Open trace
201199
reader = lcs.TraceReader(
202-
trace=dl.get_cache_path(URI),
200+
trace=URI,
203201
trace_type=lcs.TraceType.ORACLE_GENERAL_TRACE,
204202
reader_init_params=lcs.ReaderInitParam(ignore_obj_size=True),
205203
)
206204

205+
# Use native S3FIFO for reference
207206
ref_s3fifo = S3FIFO(cache_size=1024, small_size_ratio=0.1, ghost_size_ratio=0.9, move_to_main_threshold=2)
208207

209208
# for req in reader:

examples/trace_analysis.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import libcachesim as lcs
22

33
# Step 1: Get one trace from S3 bucket
4-
URI = "cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
5-
dl = lcs.DataLoader()
6-
dl.load(URI)
4+
URI = "s3://cache-datasets/cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
75

86
reader = lcs.TraceReader(
9-
trace=dl.get_cache_path(URI),
7+
trace=URI,
108
trace_type=lcs.TraceType.ORACLE_GENERAL_TRACE,
119
reader_init_params=lcs.ReaderInitParam(ignore_obj_size=False),
1210
)

src/exception.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ void register_exception(py::module& m) {
2121
try {
2222
if (p) std::rethrow_exception(p);
2323
} catch (const CacheException& e) {
24-
exc_cache(e.what());
24+
py::set_error(exc_cache, e.what());
2525
} catch (const ReaderException& e) {
26-
exc_reader(e.what());
26+
py::set_error(exc_reader, e.what());
2727
}
2828
});
2929

0 commit comments

Comments
 (0)