Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions docs/src/en/getting_started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ With libcachesim installed, you can start cache simulation for some eviction alg

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

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

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

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

# Step 1: Get one trace from S3 bucket
URI = "cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
dl = lcs.DataLoader()
dl.load(URI)

URI = "s3://cache-datasets/cache_dataset_oracleGeneral/2007_msr/msr_hm_0.oracleGeneral.zst"
reader = lcs.TraceReader(
trace = dl.get_cache_path(URI),
trace_type = lcs.TraceType.ORACLE_GENERAL_TRACE,
Expand Down Expand Up @@ -143,8 +139,7 @@ Here is an example demonstrating how to use `TraceAnalyzer`.

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

1. Download a trace file from an S3 bucket using `DataLoader`.
2. Open the trace file with `TraceReader`, specifying the trace type and any reader initialization parameters.
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.
3. Configure the analysis options with `AnalysisOption` to enable or disable specific analyses (such as request rate, size, etc.).
4. Optionally, set additional analysis parameters with `AnalysisParam`.
5. Create a `TraceAnalyzer` object with the reader, output directory, and the chosen options and parameters.
Expand Down
9 changes: 4 additions & 5 deletions examples/plugin_cache/s3fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,16 @@ def cache_free_hook(cache):
cache_name="S3FIFO",
)

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

# Step 2: Open trace and process efficiently
# Open trace
reader = lcs.TraceReader(
trace=dl.get_cache_path(URI),
trace=URI,
trace_type=lcs.TraceType.ORACLE_GENERAL_TRACE,
reader_init_params=lcs.ReaderInitParam(ignore_obj_size=True),
)

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

# for req in reader:
Expand Down
6 changes: 2 additions & 4 deletions examples/trace_analysis.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import libcachesim as lcs

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

reader = lcs.TraceReader(
trace=dl.get_cache_path(URI),
trace=URI,
trace_type=lcs.TraceType.ORACLE_GENERAL_TRACE,
reader_init_params=lcs.ReaderInitParam(ignore_obj_size=False),
)
Expand Down
4 changes: 2 additions & 2 deletions src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ void register_exception(py::module& m) {
try {
if (p) std::rethrow_exception(p);
} catch (const CacheException& e) {
exc_cache(e.what());
py::set_error(exc_cache, e.what());
} catch (const ReaderException& e) {
exc_reader(e.what());
py::set_error(exc_reader, e.what());
}
});

Expand Down
Loading