-
Notifications
You must be signed in to change notification settings - Fork 2
[Refactor] Remove data loader to simplify api #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,26 @@ | ||
| 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) | ||
|
|
||
| # Step 2: Open trace and process efficiently | ||
| # Step 1: Open a trace hosted on S3 (find more via https://github.com/cacheMon/cache_dataset) | ||
| 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), | ||
| ) | ||
|
|
||
| # Step 3: Initialize cache | ||
| cache = lcs.S3FIFO(cache_size=1024 * 1024) | ||
| # Step 2: Initialize cache | ||
| cache = lcs.S3FIFO( | ||
| cache_size=1024 * 1024, | ||
| # Cache specific parameters | ||
| small_size_ratio=0.2, | ||
| ghost_size_ratio=0.8, | ||
| move_to_main_threshold=2, | ||
| ) | ||
|
|
||
| # Step 4: Process entire trace efficiently (C++ backend) | ||
| obj_miss_ratio, byte_miss_ratio = cache.process_trace(reader) | ||
| print(f"Object miss ratio: {obj_miss_ratio:.4f}, Byte miss ratio: {byte_miss_ratio:.4f}") | ||
| # Step 3: Process entire trace efficiently (C++ backend) | ||
| req_miss_ratio, byte_miss_ratio = cache.process_trace(reader) | ||
| print(f"Request miss ratio: {req_miss_ratio:.4f}, Byte miss ratio: {byte_miss_ratio:.4f}") | ||
|
|
||
| # Step 4.1: Process with limited number of requests | ||
| cache = lcs.S3FIFO(cache_size=1024 * 1024) | ||
| obj_miss_ratio, byte_miss_ratio = cache.process_trace(reader, start_req=0, max_req=1000) | ||
| print(f"Object miss ratio: {obj_miss_ratio:.4f}, Byte miss ratio: {byte_miss_ratio:.4f}") | ||
| # Step 3.1: Further process the first 1000 requests again | ||
| req_miss_ratio, byte_miss_ratio = cache.process_trace(reader, start_req=0, max_req=1000) | ||
| print(f"Request miss ratio: {req_miss_ratio:.4f}, Byte miss ratio: {byte_miss_ratio:.4f}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is missing the re-initialization of the
cacheobject before the secondprocess_tracecall. Theprocess_tracemethod is stateful and modifies the cache. To correctly process the "first 1000 requests again" from a clean state, the cache should be re-created.