diff --git a/libCacheSim/cache/cache.c b/libCacheSim/cache/cache.c index 304fe14e..f3ce0de4 100644 --- a/libCacheSim/cache/cache.c +++ b/libCacheSim/cache/cache.c @@ -201,8 +201,8 @@ cache_obj_t *cache_find_base(cache_t *cache, const request_t *req, #endif if (update_cache) { - cache_obj->misc.next_access_vtime = req->next_access_vtime; - cache_obj->misc.freq += 1; + cache_obj->next_access_vtime = req->next_access_vtime; + cache_obj->freq += 1; } } @@ -290,8 +290,8 @@ cache_obj_t *cache_insert_base(cache_t *cache, const request_t *req) { cache_obj->create_time = CURR_TIME(cache, req); #endif - cache_obj->misc.next_access_vtime = req->next_access_vtime; - cache_obj->misc.freq = 0; + cache_obj->next_access_vtime = req->next_access_vtime; + cache_obj->freq = 0; return cache_obj; } diff --git a/libCacheSim/cache/eviction/ARC.c b/libCacheSim/cache/eviction/ARC.c index 433c2bd2..c8b22d88 100644 --- a/libCacheSim/cache/eviction/ARC.c +++ b/libCacheSim/cache/eviction/ARC.c @@ -277,9 +277,9 @@ static cache_obj_t *ARC_find(cache_t *cache, const request_t *req, prepend_obj_to_head(¶ms->L2_data_head, ¶ms->L2_data_tail, obj); #if defined(TRACK_DEMOTION) - obj->misc.next_access_vtime = req->next_access_vtime; + obj->next_access_vtime = req->next_access_vtime; printf("%ld keep %ld %ld\n", cache->n_req, obj->create_time, - obj->misc.next_access_vtime); + obj->next_access_vtime); #endif params->L1_data_size -= obj->obj_size + cache->obj_md_size; @@ -450,7 +450,7 @@ static void _ARC_evict_L1_data(cache_t *cache, const request_t *req) { #if defined(TRACK_DEMOTION) printf("%ld demote %ld %ld\n", cache->n_req, obj->create_time, - obj->misc.next_access_vtime); + obj->next_access_vtime); #endif cache_evict_base(cache, obj, false); @@ -469,7 +469,7 @@ static void _ARC_evict_L1_data_no_ghost(cache_t *cache, const request_t *req) { #if defined(TRACK_DEMOTION) printf("%ld demote %ld %ld\n", cache->n_req, obj->create_time, - obj->misc.next_access_vtime); + obj->next_access_vtime); #endif remove_obj_from_list(¶ms->L1_data_head, ¶ms->L1_data_tail, obj); diff --git a/libCacheSim/cache/eviction/ARCv0.c b/libCacheSim/cache/eviction/ARCv0.c index d8893dce..98e8c683 100644 --- a/libCacheSim/cache/eviction/ARCv0.c +++ b/libCacheSim/cache/eviction/ARCv0.c @@ -255,7 +255,7 @@ static cache_obj_t *ARCv0_find(cache_t *cache, const request_t *req, } else { // cache hit, case I: x in L1_data or L2_data if (obj_t1 != NULL) { - obj_t1->misc.freq = 1; + obj_t1->freq = 1; #ifndef LAZY_PROMOTION // move to LRU2 params->T1->remove(params->T1, obj_t1->obj_id); @@ -297,7 +297,6 @@ static cache_obj_t *ARCv0_insert(cache_t *cache, const request_t *req) { } else { // insert to L1 data head obj = params->T1->insert(params->T1, req); - obj->misc.freq = 0; } return obj; @@ -421,7 +420,7 @@ static void _ARCv0_replace(cache_t *cache, const request_t *req) { DEBUG_ASSERT(obj != NULL); copy_cache_obj_to_request(params->req_local, obj); #ifdef LAZY_PROMOTION - if (obj->misc.freq > 0) { + if (obj->freq > 0) { params->T2->get(params->T2, params->req_local); } else { params->B1->get(params->B1, params->req_local); @@ -490,7 +489,7 @@ static void _ARCv0_evict_miss_on_all_queues(cache_t *cache, cache_obj_t *obj = params->T1->to_evict(params->T1, req); DEBUG_ASSERT(obj != NULL); copy_cache_obj_to_request(params->req_local, obj); - if (obj->misc.freq > 0) { + if (obj->freq > 0) { params->T2->get(params->T2, params->req_local); } params->T1->evict(params->T1, req); diff --git a/libCacheSim/cache/eviction/FIFO_Merge.c b/libCacheSim/cache/eviction/FIFO_Merge.c index b5bf6e36..763ab61f 100644 --- a/libCacheSim/cache/eviction/FIFO_Merge.c +++ b/libCacheSim/cache/eviction/FIFO_Merge.c @@ -189,10 +189,8 @@ static cache_obj_t *FIFO_Merge_find(cache_t *cache, const request_t *req, cache_obj_t *cache_obj = cache_find_base(cache, req, update_cache); if (cache_obj && update_cache) { - cache_obj->FIFO_Merge.freq++; - + cache_obj->FIFO_Merge.freq += 1; cache_obj->FIFO_Merge.last_access_vtime = cache->n_req; - cache_obj->misc.next_access_vtime = req->next_access_vtime; } return cache_obj; @@ -216,7 +214,6 @@ static cache_obj_t *FIFO_Merge_insert(cache_t *cache, const request_t *req) { prepend_obj_to_head(¶ms->q_head, ¶ms->q_tail, cache_obj); cache_obj->FIFO_Merge.freq = 0; cache_obj->FIFO_Merge.last_access_vtime = cache->n_req; - cache_obj->misc.next_access_vtime = req->next_access_vtime; return cache_obj; } @@ -418,10 +415,10 @@ static inline int cmp_list_node(const void *a0, const void *b0) { } static inline double belady_metric(cache_t *cache, cache_obj_t *cache_obj) { - if (cache_obj->misc.next_access_vtime == -1 || - cache_obj->misc.next_access_vtime == INT64_MAX) + if (cache_obj->next_access_vtime == -1 || + cache_obj->next_access_vtime == INT64_MAX) return -1; - return 1.0e12 / (cache_obj->misc.next_access_vtime - cache->n_req) / + return 1.0e12 / (cache_obj->next_access_vtime - cache->n_req) / (double)cache_obj->obj_size; } diff --git a/libCacheSim/cache/eviction/FIFO_Reinsertion.c b/libCacheSim/cache/eviction/FIFO_Reinsertion.c index 99089836..3d68a784 100644 --- a/libCacheSim/cache/eviction/FIFO_Reinsertion.c +++ b/libCacheSim/cache/eviction/FIFO_Reinsertion.c @@ -200,7 +200,6 @@ static cache_obj_t *FIFO_Reinsertion_find(cache_t *cache, const request_t *req, if (cache_obj && update_cache) { cache_obj->FIFO_Reinsertion.freq++; cache_obj->FIFO_Reinsertion.last_access_vtime = cache->n_req; - cache_obj->misc.next_access_vtime = req->next_access_vtime; } return cache_obj; @@ -227,7 +226,6 @@ static cache_obj_t *FIFO_Reinsertion_insert(cache_t *cache, obj->FIFO_Reinsertion.freq = 0; obj->FIFO_Reinsertion.last_access_vtime = cache->n_req; - obj->misc.next_access_vtime = req->next_access_vtime; return obj; } @@ -440,10 +438,10 @@ static inline int cmp_list_node(const void *a0, const void *b0) { } static inline double belady_metric(cache_t *cache, cache_obj_t *cache_obj) { - if (cache_obj->misc.next_access_vtime == -1 || - cache_obj->misc.next_access_vtime == INT64_MAX) + if (cache_obj->next_access_vtime == -1 || + cache_obj->next_access_vtime == INT64_MAX) return -1; - return 1.0e12 / (cache_obj->misc.next_access_vtime - cache->n_req) / + return 1.0e12 / (cache_obj->next_access_vtime - cache->n_req) / (double)cache_obj->obj_size; } diff --git a/libCacheSim/cache/eviction/GLCache/obj.h b/libCacheSim/cache/eviction/GLCache/obj.h index f826a221..8900437e 100644 --- a/libCacheSim/cache/eviction/GLCache/obj.h +++ b/libCacheSim/cache/eviction/GLCache/obj.h @@ -12,7 +12,7 @@ static inline void obj_init(cache_t *cache, const request_t *req, cache_obj->GLCache.last_access_vtime = params->curr_vtime; cache_obj->GLCache.in_cache = 1; cache_obj->GLCache.seen_after_snapshot = 0; - cache_obj->misc.next_access_vtime = req->next_access_vtime; + cache_obj->next_access_vtime = req->next_access_vtime; cache_obj->GLCache.segment = seg; cache_obj->GLCache.idx_in_segment = seg->n_obj; @@ -25,7 +25,7 @@ static inline int64_t obj_age(GLCache_params_t *params, cache_obj_t *obj) { /* some internal state update when an object is requested */ static inline void obj_hit_update(GLCache_params_t *params, cache_obj_t *obj, const request_t *req) { - obj->misc.next_access_vtime = req->next_access_vtime; + obj->next_access_vtime = req->next_access_vtime; obj->GLCache.last_access_rtime = params->curr_rtime; obj->GLCache.last_access_vtime = params->curr_vtime; obj->GLCache.freq += 1; @@ -71,14 +71,14 @@ static inline double cal_obj_score(GLCache_params_t *params, (curr_rtime - cache_obj->GLCache.last_access_rtime); } else if (score_type == OBJ_SCORE_ORACLE) { - if (cache_obj->misc.next_access_vtime == -1 || - cache_obj->misc.next_access_vtime == INT64_MAX) { + if (cache_obj->next_access_vtime == -1 || + cache_obj->next_access_vtime == INT64_MAX) { return 0; } - DEBUG_ASSERT(cache_obj->misc.next_access_vtime > curr_vtime); + DEBUG_ASSERT(cache_obj->next_access_vtime > curr_vtime); return 1.0e8 / (double)cache_obj->obj_size / - (double)(cache_obj->misc.next_access_vtime - curr_vtime); + (double)(cache_obj->next_access_vtime - curr_vtime); } else { printf("unknown cache type %d\n", score_type); diff --git a/libCacheSim/cache/eviction/GLCache/segment.c b/libCacheSim/cache/eviction/GLCache/segment.c index b1399422..6e4d9563 100644 --- a/libCacheSim/cache/eviction/GLCache/segment.c +++ b/libCacheSim/cache/eviction/GLCache/segment.c @@ -230,7 +230,7 @@ double cal_seg_utility(cache_t *cache, segment_t *seg, bool oracle_obj_sel) { static int count_n_obj_reuse(cache_t *cache, segment_t *seg) { int n = 0; for (int i = 0; i < seg->n_obj; i++) { - if (seg->objs[i].misc.next_access_vtime > 0) { + if (seg->objs[i].next_access_vtime > 0) { n += 1; } } diff --git a/libCacheSim/cache/eviction/LRU.c b/libCacheSim/cache/eviction/LRU.c index c12fdb52..6dcd14c4 100644 --- a/libCacheSim/cache/eviction/LRU.c +++ b/libCacheSim/cache/eviction/LRU.c @@ -213,7 +213,7 @@ static void LRU_evict(cache_t *cache, const request_t *req) { #if defined(TRACK_DEMOTION) if (cache->track_demotion) printf("%ld demote %ld %ld\n", cache->n_req, obj_to_evict->create_time, - obj_to_evict->misc.next_access_vtime); + obj_to_evict->next_access_vtime); #endif cache_evict_base(cache, obj_to_evict, true); diff --git a/libCacheSim/cache/eviction/LRUProb.c b/libCacheSim/cache/eviction/LRUProb.c index 17638ee0..23ada9e8 100644 --- a/libCacheSim/cache/eviction/LRUProb.c +++ b/libCacheSim/cache/eviction/LRUProb.c @@ -149,9 +149,6 @@ static cache_obj_t *LRU_Prob_find(cache_t *cache, const request_t *req, cache_obj_t *cached_obj = cache_find_base(cache, req, update_cache); if (cached_obj != NULL && likely(update_cache)) { - cached_obj->misc.freq += 1; - cached_obj->misc.next_access_vtime = req->next_access_vtime; - if (next_rand() % params->threshold == 0) { move_obj_to_head(¶ms->q_head, ¶ms->q_tail, cached_obj); } diff --git a/libCacheSim/cache/eviction/LeCaR.c b/libCacheSim/cache/eviction/LeCaR.c index df3f35d3..eacf5335 100644 --- a/libCacheSim/cache/eviction/LeCaR.c +++ b/libCacheSim/cache/eviction/LeCaR.c @@ -362,9 +362,9 @@ static cache_obj_t *LeCaR_to_evict(cache_t *cache, const request_t *req) { // we divide by 1,000,000 to avoid overflow when next_access_vtime is // INT64_MAX - double lru_belady_metric = lru_choice->misc.next_access_vtime - cache->n_req; + double lru_belady_metric = lru_choice->next_access_vtime - cache->n_req; lru_belady_metric = lru_belady_metric / 1000000.0 * lru_choice->obj_size; - double lfu_belady_metric = lfu_choice->misc.next_access_vtime - cache->n_req; + double lfu_belady_metric = lfu_choice->next_access_vtime - cache->n_req; lfu_belady_metric = lfu_belady_metric / 1000000.0 * lfu_choice->obj_size; if (lru_belady_metric > lfu_belady_metric) { @@ -394,9 +394,9 @@ static void LeCaR_evict(cache_t *cache, const request_t *req) { // we divide by 1,000,000 to avoid overflow when next_access_vtime is // INT64_MAX - double lru_belady_metric = lru_choice->misc.next_access_vtime - cache->n_req; + double lru_belady_metric = lru_choice->next_access_vtime - cache->n_req; lru_belady_metric = lru_belady_metric / 1000000.0 * lru_choice->obj_size; - double lfu_belady_metric = lfu_choice->misc.next_access_vtime - cache->n_req; + double lfu_belady_metric = lfu_choice->next_access_vtime - cache->n_req; lfu_belady_metric = lfu_belady_metric / 1000000.0 * lfu_choice->obj_size; if (lru_belady_metric > lfu_belady_metric) { diff --git a/libCacheSim/cache/eviction/QDLP.c b/libCacheSim/cache/eviction/QDLP.c index e700abb8..b1edd82f 100644 --- a/libCacheSim/cache/eviction/QDLP.c +++ b/libCacheSim/cache/eviction/QDLP.c @@ -306,7 +306,7 @@ static cache_obj_t *QDLP_insert(cache_t *cache, const request_t *req) { obj->create_time = CURR_TIME(cache, req); #endif - assert(obj->misc.freq == 0); + assert(obj->freq == 0); return obj; } @@ -361,7 +361,7 @@ static void QDLP_evict(cache_t *cache, const request_t *req) { // need to copy the object before it is evicted copy_cache_obj_to_request(params->req_local, obj); - if (obj->misc.freq >= params->move_to_main_threshold) { + if (obj->freq >= params->move_to_main_threshold) { // get will insert to and evict from main cache params->n_obj_move_to_main += 1; params->n_byte_move_to_main += obj->obj_size; diff --git a/libCacheSim/cache/eviction/S3FIFOd.c b/libCacheSim/cache/eviction/S3FIFOd.c index 34e0c3a5..f04b8c75 100644 --- a/libCacheSim/cache/eviction/S3FIFOd.c +++ b/libCacheSim/cache/eviction/S3FIFOd.c @@ -371,7 +371,7 @@ static cache_obj_t *S3FIFOd_insert(cache_t *cache, const request_t *req) { obj = params->small_fifo->insert(params->small_fifo, req); } - assert(obj->misc.freq == 0); + assert(obj->freq == 0); #if defined(TRACK_EVICTION_V_AGE) obj->create_time = CURR_TIME(cache, req); @@ -431,7 +431,7 @@ static void S3FIFOd_evict(cache_t *cache, const request_t *req) { copy_cache_obj_to_request(params->req_local, obj); #if defined(TRACK_EVICTION_V_AGE) - if (obj->misc.freq >= params->move_to_main_threshold) { + if (obj->freq >= params->move_to_main_threshold) { // promote to main cache cache_obj_t *new_obj = main_fifo->insert(main_fifo, params->req_local); new_obj->create_time = obj->create_time; @@ -462,7 +462,7 @@ static void S3FIFOd_evict(cache_t *cache, const request_t *req) { bool removed = small_fifo->remove(small_fifo, params->req_local->obj_id); assert(removed); - if (obj->misc.freq >= params->move_to_main_threshold) { + if (obj->freq >= params->move_to_main_threshold) { // promote to main cache main_fifo->insert(main_fifo, params->req_local); diff --git a/libCacheSim/cache/eviction/S3FIFOv0.c b/libCacheSim/cache/eviction/S3FIFOv0.c index 09df70d5..a9caf2a5 100644 --- a/libCacheSim/cache/eviction/S3FIFOv0.c +++ b/libCacheSim/cache/eviction/S3FIFOv0.c @@ -332,7 +332,7 @@ static void S3FIFOv0_evict_small(cache_t *cache, const request_t *req) { if (obj_to_evict->S3FIFO.freq >= params->move_to_main_threshold) { #if defined(TRACK_DEMOTION) printf("%ld keep %ld %ld\n", cache->n_req, obj_to_evict->create_time, - obj_to_evict->misc.next_access_vtime); + obj_to_evict->next_access_vtime); #endif params->n_obj_move_to_main += 1; params->n_byte_move_to_main += obj_to_evict->obj_size; @@ -349,7 +349,7 @@ static void S3FIFOv0_evict_small(cache_t *cache, const request_t *req) { #if defined(TRACK_DEMOTION) printf("%ld demote %ld %ld\n", cache->n_req, obj_to_evict->create_time, - obj_to_evict->misc.next_access_vtime); + obj_to_evict->next_access_vtime); #endif // insert to ghost diff --git a/libCacheSim/cache/eviction/WTinyLFU.c b/libCacheSim/cache/eviction/WTinyLFU.c index 32f261e7..89191125 100644 --- a/libCacheSim/cache/eviction/WTinyLFU.c +++ b/libCacheSim/cache/eviction/WTinyLFU.c @@ -282,7 +282,7 @@ static void WTinyLFU_evict(cache_t *cache, const request_t *req) { #if defined(TRACK_DEMOTION) printf("%ld keep %ld %ld\n", cache->n_req, window_victim->create_time, - window_victim->misc.next_access_vtime); + window_victim->next_access_vtime); #endif params->n_admit_bytes += params->req_local->obj_size; @@ -301,7 +301,7 @@ static void WTinyLFU_evict(cache_t *cache, const request_t *req) { sizeof(main_cache_victim->obj_id))) { #if defined(TRACK_DEMOTION) printf("%ld keep %ld %ld\n", cache->n_req, window_victim->create_time, - window_victim->misc.next_access_vtime); + window_victim->next_access_vtime); #endif main_cache->evict(main_cache, req); @@ -317,8 +317,7 @@ static void WTinyLFU_evict(cache_t *cache, const request_t *req) { } else { #if defined(TRACK_DEMOTION) printf("%ld demote %ld %ld\n", cache->n_req, - window_victim->create_time, - window_victim->misc.next_access_vtime); + window_victim->create_time, window_victim->next_access_vtime); #endif window->evict(window, req); diff --git a/libCacheSim/cache/eviction/belady/FIFO_Belady.c b/libCacheSim/cache/eviction/belady/FIFO_Belady.c index fa4ae2e4..3a4c25be 100644 --- a/libCacheSim/cache/eviction/belady/FIFO_Belady.c +++ b/libCacheSim/cache/eviction/belady/FIFO_Belady.c @@ -206,7 +206,7 @@ static void FIFO_Belady_evict(cache_t *cache, const request_t *req) { DEBUG_ASSERT(params->q_tail != NULL); #ifdef USE_BELADY_EVICTION - if (should_insert(cache, obj_to_evict->misc.next_access_vtime)) { + if (should_insert(cache, obj_to_evict->next_access_vtime)) { move_obj_to_head(¶ms->q_head, ¶ms->q_tail, obj_to_evict); } else { remove_obj_from_list(¶ms->q_head, ¶ms->q_tail, obj_to_evict); diff --git a/libCacheSim/cache/eviction/belady/LRU_Belady.c b/libCacheSim/cache/eviction/belady/LRU_Belady.c index 3c6a0f70..a8391c80 100644 --- a/libCacheSim/cache/eviction/belady/LRU_Belady.c +++ b/libCacheSim/cache/eviction/belady/LRU_Belady.c @@ -222,7 +222,7 @@ static void LRU_Belady_evict(cache_t *cache, const request_t *req) { DEBUG_ASSERT(params->q_tail != NULL); #ifdef USE_BELADY_EVICTION - if (should_insert(cache, obj_to_evict->misc.next_access_vtime)) { + if (should_insert(cache, obj_to_evict->next_access_vtime)) { move_obj_to_head(¶ms->q_head, ¶ms->q_tail, obj_to_evict); } else { remove_obj_from_list(¶ms->q_head, ¶ms->q_tail, obj_to_evict); diff --git a/libCacheSim/cache/eviction/belady/Sieve_Belady.c b/libCacheSim/cache/eviction/belady/Sieve_Belady.c index 1a3b0300..6b70196e 100644 --- a/libCacheSim/cache/eviction/belady/Sieve_Belady.c +++ b/libCacheSim/cache/eviction/belady/Sieve_Belady.c @@ -232,7 +232,7 @@ static void Sieve_Belady_evict(cache_t *cache, const request_t *req) { } /* find the first untouched */ - while (obj != NULL && should_insert(cache, obj->misc.next_access_vtime)) { + while (obj != NULL && should_insert(cache, obj->next_access_vtime)) { // while (obj != NULL && obj->sieve.freq > 0) { obj->sieve.freq -= 1; obj = obj->queue.prev; @@ -241,7 +241,7 @@ static void Sieve_Belady_evict(cache_t *cache, const request_t *req) { /* if we have finished one around, start from the tail */ if (obj == NULL) { obj = params->q_tail; - while (obj != NULL && should_insert(cache, obj->misc.next_access_vtime)) { + while (obj != NULL && should_insert(cache, obj->next_access_vtime)) { // while (obj != NULL && obj->sieve.freq > 0) { obj->sieve.freq -= 1; obj = obj->queue.prev; diff --git a/libCacheSim/cache/eviction/cpp/GDSF.cpp b/libCacheSim/cache/eviction/cpp/GDSF.cpp index d5c3fbc5..f3bb2c4f 100644 --- a/libCacheSim/cache/eviction/cpp/GDSF.cpp +++ b/libCacheSim/cache/eviction/cpp/GDSF.cpp @@ -146,14 +146,13 @@ static cache_obj_t *GDSF_find(cache_t *cache, const request_t *req, cache_obj_t *obj = cache_find_base(cache, req, update_cache); /* this does not consider object size change */ if (obj != nullptr && update_cache) { - /* misc frequency is updated in cache_find_base */ - // obj->misc.freq += 1; + /* frequency is updated in cache_find_base */ auto node = gdsf->pq_map[obj]; gdsf->pq.erase(node); double pri = - gdsf->pri_last_evict + (double)(obj->misc.freq) * 1.0e6 / obj->obj_size; + gdsf->pri_last_evict + (double)(obj->freq) * 1.0e6 / obj->obj_size; eviction::pq_node_type new_node = {obj, pri, cache->n_req}; gdsf->pq.insert(new_node); gdsf->pq_map[obj] = new_node; @@ -233,7 +232,10 @@ static cache_obj_t *GDSF_insert(cache_t *cache, const request_t *req) { cache_obj_t *obj = cache_insert_base(cache, req); DEBUG_ASSERT(obj != nullptr); - obj->misc.freq = 1; + // default freq is 0, we need to set it to 1 because GDSF uses freq as part of + // priority calculation and if it is 0, the object will have the same priority + // as an object that is not accessed at all and it will be evicted immediately + obj->freq = 1; double pri = gdsf->pri_last_evict + 1.0e6 / obj->obj_size; eviction::pq_node_type new_node = {obj, pri, cache->n_req}; diff --git a/libCacheSim/cache/eviction/fifo/SFIFOv0.c b/libCacheSim/cache/eviction/fifo/SFIFOv0.c index 425b7d18..4ee5a8db 100644 --- a/libCacheSim/cache/eviction/fifo/SFIFOv0.c +++ b/libCacheSim/cache/eviction/fifo/SFIFOv0.c @@ -193,9 +193,9 @@ static cache_obj_t *SFIFOv0_find(cache_t *cache, const request_t *req, SFIFOv0_cool(cache, req, i + 1); cache_obj_t *new_obj = next_fifo->insert(next_fifo, req); - new_obj->misc.next_access_vtime = req->next_access_vtime; + new_obj->next_access_vtime = req->next_access_vtime; } else { - obj->misc.next_access_vtime = req->next_access_vtime; + obj->next_access_vtime = req->next_access_vtime; } return obj; @@ -224,7 +224,7 @@ static cache_obj_t *SFIFOv0_insert(cache_t *cache, const request_t *req) { if (fifo->get_occupied_byte(fifo) + req->obj_size + cache->obj_md_size <= fifo->cache_size) { cache_obj_t *obj = fifo->insert(fifo, req); - obj->misc.next_access_vtime = req->next_access_vtime; + obj->next_access_vtime = req->next_access_vtime; return obj; } } @@ -232,7 +232,7 @@ static cache_obj_t *SFIFOv0_insert(cache_t *cache, const request_t *req) { // If all FIFOs are filled, insert into the lowest FIFO. cache_t *fifo = params->FIFOs[0]; cache_obj_t *obj = fifo->insert(fifo, req); - obj->misc.next_access_vtime = req->next_access_vtime; + obj->next_access_vtime = req->next_access_vtime; return obj; } diff --git a/libCacheSim/cache/eviction/other/S3LRU.c b/libCacheSim/cache/eviction/other/S3LRU.c index cc64a8d8..7fe72adc 100644 --- a/libCacheSim/cache/eviction/other/S3LRU.c +++ b/libCacheSim/cache/eviction/other/S3LRU.c @@ -247,7 +247,7 @@ static cache_obj_t *S3LRU_find(cache_t *cache, const request_t *req, // move to main cache #if defined(TRACK_DEMOTION) printf("%ld keep %ld %ld\n", cache->n_req, obj->create_time, - obj->misc.next_access_vtime); + obj->next_access_vtime); #endif params->LRU->remove(params->LRU, req->obj_id); params->main_cache->insert(params->main_cache, req); @@ -343,14 +343,14 @@ static void S3LRU_evict_LRU(cache_t *cache, const request_t *req) { // move to main cache #if defined(TRACK_DEMOTION) printf("%ld keep %ld %ld\n", cache->n_req, obj_to_evict->create_time, - obj_to_evict->misc.next_access_vtime); + obj_to_evict->next_access_vtime); #endif main_cache->insert(main_cache, params->req_local); } else { #if defined(TRACK_DEMOTION) printf("%ld demote %ld %ld\n", cache->n_req, obj_to_evict->create_time, - obj_to_evict->misc.next_access_vtime); + obj_to_evict->next_access_vtime); #endif has_evicted = true; // insert to ghost diff --git a/libCacheSim/include/libCacheSim/cache.h b/libCacheSim/include/libCacheSim/cache.h index 575b05ec..44ff05bf 100644 --- a/libCacheSim/include/libCacheSim/cache.h +++ b/libCacheSim/include/libCacheSim/cache.h @@ -329,7 +329,7 @@ static inline void record_eviction_age(cache_t *cache, cache_obj_t *obj, #if defined(TRACK_EVICTION_V_AGE) // note that the frequency is not correct for QDLP and Clock if (obj->obj_id % 101 == 0) { - printf("%ld: %lu %ld %d\n", cache->n_req, obj->obj_id, age, obj->misc.freq); + printf("%ld: %lu %ld %d\n", cache->n_req, obj->obj_id, age, obj->freq); } #endif diff --git a/libCacheSim/include/libCacheSim/cacheObj.h b/libCacheSim/include/libCacheSim/cacheObj.h index 3fe3ea7b..7fe6859a 100644 --- a/libCacheSim/include/libCacheSim/cacheObj.h +++ b/libCacheSim/include/libCacheSim/cacheObj.h @@ -143,11 +143,6 @@ typedef struct { int32_t freq; } __attribute__((packed)) Sieve_obj_params_t; -typedef struct { - int64_t next_access_vtime; - int32_t freq; -} __attribute__((packed)) misc_metadata_t; - // ############################## cache obj ################################### struct cache_obj; typedef struct cache_obj { @@ -158,6 +153,10 @@ typedef struct cache_obj { struct cache_obj *prev; struct cache_obj *next; } queue; // for LRU, FIFO, etc. + + int64_t next_access_vtime; + int32_t freq; + #ifdef SUPPORT_TTL uint32_t exp_time; #endif @@ -166,8 +165,6 @@ typedef struct cache_obj { defined(TRACK_CREATE_TIME) int64_t create_time; #endif - // used by belady related algorithms - misc_metadata_t misc; union { LFU_obj_metadata_t lfu; // for LFU @@ -209,7 +206,7 @@ static inline void copy_cache_obj_to_request(request_t *req_dest, const cache_obj_t *cache_obj) { req_dest->obj_id = cache_obj->obj_id; req_dest->obj_size = cache_obj->obj_size; - req_dest->next_access_vtime = cache_obj->misc.next_access_vtime; + req_dest->next_access_vtime = cache_obj->next_access_vtime; req_dest->valid = true; }