From e90eb8e3637e1ce7eb46c21534fcf2c520ec3d90 Mon Sep 17 00:00:00 2001 From: Juncheng Yang Date: Tue, 5 Nov 2024 22:44:46 -0500 Subject: [PATCH] fix a bug where admission is not enabled for some algorithms (#100) fix a bug in macro Co-authored-by: Juncheng Yang --- libCacheSim/cache/admission/prob.c | 3 ++- libCacheSim/cache/admission/size.c | 9 ++++----- libCacheSim/cache/eviction/QDLP.c | 2 +- libCacheSim/cache/eviction/S3FIFO.c | 2 +- libCacheSim/cache/eviction/S3FIFOd.c | 2 +- libCacheSim/cache/eviction/S3FIFOv0.c | 2 +- libCacheSim/cache/eviction/TwoQ.c | 2 +- libCacheSim/cache/eviction/other/S3LRU.c | 2 +- libCacheSim/cache/eviction/priv/S3FIFOdv2.c | 2 +- libCacheSim/include/libCacheSim/logging.h | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libCacheSim/cache/admission/prob.c b/libCacheSim/cache/admission/prob.c index 5f7a0340..bd802827 100644 --- a/libCacheSim/cache/admission/prob.c +++ b/libCacheSim/cache/admission/prob.c @@ -29,7 +29,7 @@ static void prob_admissioner_parse_params(const char *init_params, prob_admission_params_t *pa) { if (init_params == NULL) { pa->admission_probability = 0.5; - INFO("use default admission probability: %f", pa->admission_probability); + INFO("use default admission probability: %f\n", pa->admission_probability); } else { char *params_str = strdup(init_params); char *old_params_str = params_str; @@ -51,6 +51,7 @@ static void prob_admissioner_parse_params(const char *init_params, if (strlen(end) > 2) { ERROR("param parsing error, find string \"%s\" after number\n", end); } + INFO("use admission probability: %f\n", pa->admission_probability); } else { ERROR("probabilistic admission does not have parameter %s\n", key); } diff --git a/libCacheSim/cache/admission/size.c b/libCacheSim/cache/admission/size.c index e3f80022..fb9064c1 100644 --- a/libCacheSim/cache/admission/size.c +++ b/libCacheSim/cache/admission/size.c @@ -22,11 +22,10 @@ bool size_admit(admissioner_t *admissioner, const request_t *req) { return false; } -static void size_admissioner_parse_params(const char *init_params, - size_admission_params_t *pa) { +static void size_admissioner_parse_params(const char *init_params, size_admission_params_t *pa) { if (init_params == NULL) { pa->size_threshold = INT64_MAX; - INFO("use default size admission: %ld", (long)pa->size_threshold); + INFO("use default size admission: %ld\n", (long)pa->size_threshold); } else { char *params_str = strdup(init_params); char *old_params_str = params_str; @@ -48,6 +47,7 @@ static void size_admissioner_parse_params(const char *init_params, if (strlen(end) > 2) { ERROR("param parsing error, find string \"%s\" after number\n", end); } + INFO("use size threshold: %ld\n", (long)pa->size_threshold); } else { ERROR("size admission does not have parameter %s\n", key); } @@ -71,8 +71,7 @@ void free_size_admissioner(admissioner_t *admissioner) { } admissioner_t *create_size_admissioner(const char *init_params) { - size_admission_params_t *pa = - (size_admission_params_t *)malloc(sizeof(size_admission_params_t)); + size_admission_params_t *pa = (size_admission_params_t *)malloc(sizeof(size_admission_params_t)); memset(pa, 0, sizeof(size_admission_params_t)); size_admissioner_parse_params(init_params, pa); diff --git a/libCacheSim/cache/eviction/QDLP.c b/libCacheSim/cache/eviction/QDLP.c index af2758ec..dcc6fd9b 100644 --- a/libCacheSim/cache/eviction/QDLP.c +++ b/libCacheSim/cache/eviction/QDLP.c @@ -419,7 +419,7 @@ static inline int64_t QDLP_get_n_obj(const cache_t *cache) { static inline bool QDLP_can_insert(cache_t *cache, const request_t *req) { QDLP_params_t *params = (QDLP_params_t *)cache->eviction_params; - return req->obj_size <= params->fifo->cache_size; + return req->obj_size <= params->fifo->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/S3FIFO.c b/libCacheSim/cache/eviction/S3FIFO.c index 34f4df9f..b527f308 100644 --- a/libCacheSim/cache/eviction/S3FIFO.c +++ b/libCacheSim/cache/eviction/S3FIFO.c @@ -473,7 +473,7 @@ static inline int64_t S3FIFO_get_n_obj(const cache_t *cache) { static inline bool S3FIFO_can_insert(cache_t *cache, const request_t *req) { S3FIFO_params_t *params = (S3FIFO_params_t *)cache->eviction_params; - return req->obj_size <= params->fifo->cache_size; + return req->obj_size <= params->fifo->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/S3FIFOd.c b/libCacheSim/cache/eviction/S3FIFOd.c index 5b73b814..10dde756 100644 --- a/libCacheSim/cache/eviction/S3FIFOd.c +++ b/libCacheSim/cache/eviction/S3FIFOd.c @@ -515,7 +515,7 @@ static inline int64_t S3FIFOd_get_n_obj(const cache_t *cache) { static inline bool S3FIFOd_can_insert(cache_t *cache, const request_t *req) { S3FIFOd_params_t *params = (S3FIFOd_params_t *)cache->eviction_params; - return req->obj_size <= params->fifo->cache_size; + return req->obj_size <= params->fifo->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/S3FIFOv0.c b/libCacheSim/cache/eviction/S3FIFOv0.c index d0b3139a..68eced78 100644 --- a/libCacheSim/cache/eviction/S3FIFOv0.c +++ b/libCacheSim/cache/eviction/S3FIFOv0.c @@ -479,7 +479,7 @@ static inline int64_t S3FIFOv0_get_n_obj(const cache_t *cache) { static inline bool S3FIFOv0_can_insert(cache_t *cache, const request_t *req) { S3FIFOv0_params_t *params = (S3FIFOv0_params_t *)cache->eviction_params; - return req->obj_size <= params->fifo->cache_size; + return req->obj_size <= params->fifo->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/TwoQ.c b/libCacheSim/cache/eviction/TwoQ.c index e2041afc..f96b04ce 100644 --- a/libCacheSim/cache/eviction/TwoQ.c +++ b/libCacheSim/cache/eviction/TwoQ.c @@ -314,7 +314,7 @@ static inline int64_t TwoQ_get_n_obj(const cache_t *cache) { static inline bool TwoQ_can_insert(cache_t *cache, const request_t *req) { TwoQ_params_t *params = (TwoQ_params_t *)cache->eviction_params; - return req->obj_size <= params->Ain->cache_size; + return req->obj_size <= params->Ain->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/other/S3LRU.c b/libCacheSim/cache/eviction/other/S3LRU.c index 5cf499fe..b51f8805 100644 --- a/libCacheSim/cache/eviction/other/S3LRU.c +++ b/libCacheSim/cache/eviction/other/S3LRU.c @@ -444,7 +444,7 @@ static inline int64_t S3LRU_get_n_obj(const cache_t *cache) { static inline bool S3LRU_can_insert(cache_t *cache, const request_t *req) { S3LRU_params_t *params = (S3LRU_params_t *)cache->eviction_params; - return req->obj_size <= params->LRU->cache_size; + return req->obj_size <= params->LRU->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/cache/eviction/priv/S3FIFOdv2.c b/libCacheSim/cache/eviction/priv/S3FIFOdv2.c index 6598a07e..1a04075e 100644 --- a/libCacheSim/cache/eviction/priv/S3FIFOdv2.c +++ b/libCacheSim/cache/eviction/priv/S3FIFOdv2.c @@ -825,7 +825,7 @@ static inline int64_t S3FIFOdv2_get_n_obj(const cache_t *cache) { static inline bool S3FIFOdv2_can_insert(cache_t *cache, const request_t *req) { S3FIFOdv2_params_t *params = (S3FIFOdv2_params_t *)cache->eviction_params; - return req->obj_size <= params->fifo->cache_size; + return req->obj_size <= params->fifo->cache_size && cache_can_insert_default(cache, req); } // *********************************************************************** diff --git a/libCacheSim/include/libCacheSim/logging.h b/libCacheSim/include/libCacheSim/logging.h index a900b235..6d0129fb 100644 --- a/libCacheSim/include/libCacheSim/logging.h +++ b/libCacheSim/include/libCacheSim/logging.h @@ -88,7 +88,7 @@ extern pthread_mutex_t log_mtx; do { \ static bool printed = false; \ if (!printed) { \ - WARN(FMT, ##__VA_ARGS__); \ + DEBUG(FMT, ##__VA_ARGS__); \ printed = true; \ fflush(stdout); \ } \