Skip to content

Commit 9747163

Browse files
committed
fix: Mithril handle_find is only called when occuring real user requests
1 parent c9138ab commit 9747163

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

libCacheSim/cache/cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ cache_obj_t *cache_find_base(cache_t *cache, const request_t *req,
153153
const bool update_cache) {
154154
cache_obj_t *cache_obj = hashtable_find(cache->hashtable, req);
155155

156-
if (cache->prefetcher && cache->prefetcher->handle_find) {
156+
// "update_cache = true" means that it is a real user request, use handle_find
157+
// to update prefetcher's state
158+
if (cache->prefetcher && cache->prefetcher->handle_find && update_cache) {
157159
bool hit = (cache_obj != NULL);
158160
cache->prefetcher->handle_find(cache, req, hit);
159161
}

libCacheSim/cache/prefetch/Mithril.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ void Mithril_prefetch(cache_t *cache, const request_t *req) {
358358
Mithril_params->num_of_check += 1;
359359
}
360360

361-
// can't use Mithril_find here
362361
if (cache->find(cache, new_req, false)) {
363362
continue;
364363
}
@@ -387,7 +386,7 @@ void Mithril_prefetch(cache_t *cache, const request_t *req) {
387386
new_req->obj_id = req->obj_id + 1;
388387
new_req->obj_size = req->obj_size; // same size
389388

390-
if (cache->find(cache, new_req, true)) {
389+
if (cache->find(cache, new_req, false)) {
391390
my_free(sizeof(request_t), new_req);
392391
return;
393392
}

test/test_prefetchAlgo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ static void print_results(const cache_t *cache, const cache_stat_t *res) {
4545
}
4646

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

5353
reader_t *reader = (reader_t *)user_data;

0 commit comments

Comments
 (0)