Skip to content

Commit

Permalink
fix a bug where admission is not enabled for some algorithms (#100)
Browse files Browse the repository at this point in the history
fix a bug in macro

Co-authored-by: Juncheng Yang <[email protected]>
  • Loading branch information
jycmu2024 and Juncheng Yang authored Nov 6, 2024
1 parent 5b87110 commit e90eb8e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion libCacheSim/cache/admission/prob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
9 changes: 4 additions & 5 deletions libCacheSim/cache/admission/size.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/QDLP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/S3FIFO.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/S3FIFOd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/S3FIFOv0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/TwoQ.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/other/S3LRU.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/cache/eviction/priv/S3FIFOdv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/include/libCacheSim/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
} \
Expand Down

0 comments on commit e90eb8e

Please sign in to comment.