From 7a8abd54afa7699fed8027489c60daf5cd8d0d21 Mon Sep 17 00:00:00 2001 From: bobob Date: Fri, 4 Oct 2024 00:33:08 -0400 Subject: [PATCH] update --- libCacheSim/cache/eviction/HOTCache.c | 13 +++++++------ libCacheSim/cache/eviction/LRU.c | 3 --- libCacheSim/cache/eviction/LRUdelay.c | 4 ++-- libCacheSim/cache/eviction/lpFIFO_batch.c | 7 ++----- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/libCacheSim/cache/eviction/HOTCache.c b/libCacheSim/cache/eviction/HOTCache.c index f1da7481..fc0321e4 100644 --- a/libCacheSim/cache/eviction/HOTCache.c +++ b/libCacheSim/cache/eviction/HOTCache.c @@ -292,11 +292,11 @@ static cache_obj_t *HOTCache_find(cache_t *cache, const request_t *req, DEBUG_ASSERT(update_cache == true); // only support this mode cache_obj_t *obj_buf = hashtable_find_obj_id(cache -> hashtable, req -> obj_id); if (obj_buf != NULL){ - // obj_buf -> misc.freq++; - // if (obj_buf -> misc.freq > params -> highest_freq){ - // params -> highest_freq = obj_buf -> misc.freq; - // } - // params -> found_in_buffer++; + obj_buf -> misc.freq++; + if (obj_buf -> misc.freq > params -> highest_freq){ + params -> highest_freq = obj_buf -> misc.freq; + } + params -> found_in_buffer++; return obj_buf; } @@ -313,7 +313,7 @@ static cache_obj_t *HOTCache_find(cache_t *cache, const request_t *req, // delete the previous object in the hashtable // get the candidate object cache_obj_t *candidate_to_delete = params -> buffer[params -> slots_buffer]; - if (candidate_to_delete && (cache -> hashtable, candidate_to_delete -> obj_id)){ + if (candidate_to_delete && hashtable_find_obj_id(cache -> hashtable, candidate_to_delete -> obj_id)){ // printf("delete obj id: %d\n", candidate_to_delete -> obj_id); hashtable_delete_obj_id(cache -> hashtable, candidate_to_delete -> obj_id); } @@ -325,6 +325,7 @@ static cache_obj_t *HOTCache_find(cache_t *cache, const request_t *req, cache_obj_t* new = hashtable_insert(cache -> hashtable, req); params -> buffer[params -> slots_buffer] = new; + new -> misc.freq = cached_obj -> misc.freq; params -> slots_buffer++; } return cached_obj; diff --git a/libCacheSim/cache/eviction/LRU.c b/libCacheSim/cache/eviction/LRU.c index 515a55bf..c2c4de81 100644 --- a/libCacheSim/cache/eviction/LRU.c +++ b/libCacheSim/cache/eviction/LRU.c @@ -134,7 +134,6 @@ static bool LRU_get(cache_t *cache, const request_t *req) { */ static cache_obj_t *LRU_find(cache_t *cache, const request_t *req, const bool update_cache) { - clock_t start = clock(); LRU_params_t *params = (LRU_params_t *)cache->eviction_params; cache_obj_t *cache_obj = cache_find_base(cache, req, update_cache); @@ -148,8 +147,6 @@ static cache_obj_t *LRU_find(cache_t *cache, const request_t *req, cache -> n_promotion++; params -> n_promotion++; } - clock_t end = clock(); - printf("LRU_find: %f\n", (double)(end - start) / CLOCKS_PER_SEC); return cache_obj; } diff --git a/libCacheSim/cache/eviction/LRUdelay.c b/libCacheSim/cache/eviction/LRUdelay.c index 7edce56f..0df5b7bb 100644 --- a/libCacheSim/cache/eviction/LRUdelay.c +++ b/libCacheSim/cache/eviction/LRUdelay.c @@ -162,9 +162,9 @@ static cache_obj_t *LRU_delay_find(cache_t *cache, const request_t *req, return NULL; } - int threshold = MIN(cache_obj->misc.freq, (int)round(0.2/ params->delay_ratio)); + // int threshold = MIN(cache_obj->misc.freq, (int)round(0.2/ params->delay_ratio)); // printf("freq %d threshold: %d %lf %d\n", cache_obj->misc.freq, threshold, params->delay_ratio, (int)round(0.2/ params->delay_ratio)); - if (cache_obj && likely(update_cache) && params->n_insertion - cache_obj->delay_count.last_promo_vtime > threshold * params->delay_time) { + if (cache_obj && likely(update_cache) && params->n_insertion - cache_obj->delay_count.last_promo_vtime > params->delay_time) { /* lru_head is the newest, move cur obj to lru_head */ #ifdef USE_BELADY if (req->next_access_vtime != INT64_MAX) diff --git a/libCacheSim/cache/eviction/lpFIFO_batch.c b/libCacheSim/cache/eviction/lpFIFO_batch.c index 02c6d59d..242d6631 100644 --- a/libCacheSim/cache/eviction/lpFIFO_batch.c +++ b/libCacheSim/cache/eviction/lpFIFO_batch.c @@ -133,7 +133,7 @@ cache_t *lpFIFO_batch_init(const common_cache_params_t ccache_params, */ static void lpFIFO_batch_free(cache_t *cache) { lpFIFO_batch_params_t *params = (lpFIFO_batch_params_t *)(cache->eviction_params); - printf("total promotion: %d\n", params->num_promotion); + // printf("total promotion: %d\n", params->num_promotion); free(params->buffer); free(cache->eviction_params); cache_struct_free(cache); @@ -180,7 +180,6 @@ static bool lpFIFO_batch_get(cache_t *cache, const request_t *req) { */ static cache_obj_t *lpFIFO_batch_find(cache_t *cache, const request_t *req, const bool update_cache) { - clock_t start = clock(); lpFIFO_batch_params_t *params = (lpFIFO_batch_params_t *)cache->eviction_params; cache_obj_t *obj = cache_find_base(cache, req, update_cache); @@ -201,8 +200,6 @@ static cache_obj_t *lpFIFO_batch_find(cache_t *cache, const request_t *req, obj->next_access_vtime = req->next_access_vtime; #endif } - clock_t end = clock(); - printf("find time: %f\n", (double)(end - start) / CLOCKS_PER_SEC); return obj; } @@ -285,7 +282,6 @@ static void lpFIFO_batch_evict(cache_t *cache, const request_t *req) { */ static void lpFIFO_batch_promote_all(cache_t *cache, const request_t *req, uint64_t *buff, const uint64_t* start) { lpFIFO_batch_params_t *params = (lpFIFO_batch_params_t *)cache->eviction_params; - params->num_promotion++; uint64_t pos = 0; uint64_t count = 0; if (*start > params->buffer_size) { @@ -307,6 +303,7 @@ static void lpFIFO_batch_promote_all(cache_t *cache, const request_t *req, uint6 if (hashtable_find_obj_id(duplicate_table, obj_to_promote) == NULL){ hashtable_f_insert_obj(duplicate_table, obj); cache -> n_promotion += 1; + params->num_promotion++; } } pos += 1;