Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobob committed Oct 4, 2024
1 parent cb2c4a4 commit 7a8abd5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
13 changes: 7 additions & 6 deletions libCacheSim/cache/eviction/HOTCache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand All @@ -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;
}

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

Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 7a8abd5

Please sign in to comment.