Skip to content

Commit

Permalink
fix: Mithril handle_find is only called when occuring real user requests
Browse files Browse the repository at this point in the history
  • Loading branch information
zztaki committed Aug 17, 2023
1 parent c9138ab commit 9747163
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion libCacheSim/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ cache_obj_t *cache_find_base(cache_t *cache, const request_t *req,
const bool update_cache) {
cache_obj_t *cache_obj = hashtable_find(cache->hashtable, req);

if (cache->prefetcher && cache->prefetcher->handle_find) {
// "update_cache = true" means that it is a real user request, use handle_find
// to update prefetcher's state
if (cache->prefetcher && cache->prefetcher->handle_find && update_cache) {
bool hit = (cache_obj != NULL);
cache->prefetcher->handle_find(cache, req, hit);
}
Expand Down
3 changes: 1 addition & 2 deletions libCacheSim/cache/prefetch/Mithril.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ void Mithril_prefetch(cache_t *cache, const request_t *req) {
Mithril_params->num_of_check += 1;
}

// can't use Mithril_find here
if (cache->find(cache, new_req, false)) {
continue;
}
Expand Down Expand Up @@ -387,7 +386,7 @@ void Mithril_prefetch(cache_t *cache, const request_t *req) {
new_req->obj_id = req->obj_id + 1;
new_req->obj_size = req->obj_size; // same size

if (cache->find(cache, new_req, true)) {
if (cache->find(cache, new_req, false)) {
my_free(sizeof(request_t), new_req);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_prefetchAlgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ static void print_results(const cache_t *cache, const cache_stat_t *res) {
}

static void test_Mithril(gconstpointer user_data) {
uint64_t miss_cnt_true[] = {79999, 78490, 76128, 75257,
uint64_t miss_cnt_true[] = {79796, 78480, 76126, 75256,
72336, 72062, 71936, 71667};
uint64_t miss_byte_true[] = {3483394560, 3398693888, 3285270016, 3245235712,
uint64_t miss_byte_true[] = {3471357440, 3399726080, 3285093888, 3245231616,
3092759040, 3077801472, 3075234816, 3061489664};

reader_t *reader = (reader_t *)user_data;
Expand Down

0 comments on commit 9747163

Please sign in to comment.