Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libCacheSim/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions libCacheSim/cache/eviction/ARC.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ static cache_obj_t *ARC_find(cache_t *cache, const request_t *req,
prepend_obj_to_head(&params->L2_data_head, &params->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;
Expand Down Expand Up @@ -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);
Expand All @@ -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(&params->L1_data_head, &params->L1_data_tail, obj);
Expand Down
7 changes: 3 additions & 4 deletions libCacheSim/cache/eviction/ARCv0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 4 additions & 7 deletions libCacheSim/cache/eviction/FIFO_Merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Comment thread
1a1a11a marked this conversation as resolved.
cache_obj->FIFO_Merge.freq++;

cache_obj->FIFO_Merge.freq += 1;
cache_obj->FIFO_Merge.last_access_vtime = cache->n_req;
Comment thread
1a1a11a marked this conversation as resolved.
cache_obj->misc.next_access_vtime = req->next_access_vtime;
}

return cache_obj;
Expand All @@ -216,7 +214,6 @@ static cache_obj_t *FIFO_Merge_insert(cache_t *cache, const request_t *req) {
prepend_obj_to_head(&params->q_head, &params->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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 3 additions & 5 deletions libCacheSim/cache/eviction/FIFO_Reinsertion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 6 additions & 6 deletions libCacheSim/cache/eviction/GLCache/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/GLCache/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/LRU.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions libCacheSim/cache/eviction/LRUProb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params->q_head, &params->q_tail, cached_obj);
}
Expand Down
8 changes: 4 additions & 4 deletions libCacheSim/cache/eviction/LeCaR.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions libCacheSim/cache/eviction/QDLP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions libCacheSim/cache/eviction/S3FIFOd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions libCacheSim/cache/eviction/S3FIFOv0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions libCacheSim/cache/eviction/WTinyLFU.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/belady/FIFO_Belady.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params->q_head, &params->q_tail, obj_to_evict);
} else {
remove_obj_from_list(&params->q_head, &params->q_tail, obj_to_evict);
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/belady/LRU_Belady.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params->q_head, &params->q_tail, obj_to_evict);
} else {
remove_obj_from_list(&params->q_head, &params->q_tail, obj_to_evict);
Expand Down
4 changes: 2 additions & 2 deletions libCacheSim/cache/eviction/belady/Sieve_Belady.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions libCacheSim/cache/eviction/cpp/GDSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
Loading
Loading