Skip to content
Open
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
10 changes: 7 additions & 3 deletions libCacheSim/cache/eviction/SLRU.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ static cache_obj_t *SLRU_insert(cache_t *cache, const request_t *req) {

if (nth_seg == -1) {
// No space for insertion
int64_t sz = req->obj_size + cache->obj_md_size;
while (params->lru_n_bytes[0] + sz > params->lru_max_n_bytes[0] ||
cache->occupied_byte + sz > cache->cache_size) {
while (cache->occupied_byte + req->obj_size + cache->obj_md_size >
cache->cache_size) {
cache->evict(cache, req);
}
nth_seg = 0;
Expand Down Expand Up @@ -382,6 +381,9 @@ static void SLRU_evict(cache_t *cache, const request_t *req) {
SLRU_params_t *params = (SLRU_params_t *)(cache->eviction_params);

cache_obj_t *obj = SLRU_to_evict(cache, req);
if (obj == NULL) {
ERROR("SLRU: no object to evict\n");
}

params->lru_n_bytes[obj->SLRU.lru_id] -= obj->obj_size + cache->obj_md_size;
params->lru_n_objs[obj->SLRU.lru_id]--;
Expand Down Expand Up @@ -412,6 +414,8 @@ static bool SLRU_remove(cache_t *cache, obj_id_t obj_id) {
return false;
}

params->lru_n_bytes[obj->SLRU.lru_id] -= obj->obj_size + cache->obj_md_size;
params->lru_n_objs[obj->SLRU.lru_id]--;
remove_obj_from_list(&(params->lru_heads[obj->SLRU.lru_id]),
&(params->lru_tails[obj->SLRU.lru_id]), obj);
cache_remove_obj_base(cache, obj, true);
Expand Down
11 changes: 9 additions & 2 deletions libCacheSim/cache/eviction/WTinyLFU.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,14 @@ static void WTinyLFU_evict(cache_t *cache, const request_t *req) {
* caller asking the composite what it reserves is not told less than it
* really does; using it here would bill a FIFO or Clock main cache for
* the window's 16 bytes and call it full early. */
if (!params->main_full &&
WTinyLFU_main_fits(main_cache, params->req_local)) {
if (params->req_local->obj_size + main_cache->obj_md_size >
main_cache->cache_size) {
// the hill climber can shrink the main cache below this object
window->evict(window, req);
evicted = true;
} else if ((!params->main_full ||
main_cache->get_n_obj(main_cache) == 0) &&
WTinyLFU_main_fits(main_cache, params->req_local)) {
main_cache->insert(main_cache, params->req_local);

#if defined(TRACK_DEMOTION)
Expand Down Expand Up @@ -462,6 +468,7 @@ static bool WTinyLFU_remove(cache_t *cache, obj_id_t obj_id) {
return true;
}
if (params->main_cache->remove(params->main_cache, obj_id)) {
params->main_full = false;
return true;
}
return false;
Expand Down
3 changes: 3 additions & 0 deletions test/test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ expect_output "WTinyLFU reports hill-climb=1" "hill-climb=1" \
expect_clean_error "WTinyLFU hill-climb rejects a FIFO main cache" \
"${BIN_DIR}/cachesim" "${TRACE}" vscsi wtinyLFU 1mb \
--num-req=10 --hashpower=8 -e "main-cache=FIFO,hill-climb=1"
expect_ok "WTinyLFU hill-climb runs with a small LRU main cache" \
"${BIN_DIR}/cachesim" "${TRACE}" vscsi wtinyLFU 256kb \
--hashpower=8 -e "main-cache=LRU,hill-climb=1"

echo "running admission and prefetch missing-value tests"

Expand Down
6 changes: 3 additions & 3 deletions test/test_evictionAlgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ static const cache_test_data_t test_data_truth[] = {
.hashpower = 20,
.req_cnt_true = 113872,
.req_byte_true = 4368040448,
.miss_cnt_true = {89862, 86685, 83365, 80309, 75447, 66000, 59092, 56111},
.miss_byte_true = {4125897728, 3909879808, 3697543168, 3489533952,
3159642624, 2695841792, 2506203648, 2440419840}},
.miss_cnt_true = {89624, 86725, 82781, 80203, 75388, 65645, 59035, 56063},
.miss_byte_true = {4123085312, 3915534848, 3690704896, 3493027840,
3174708736, 2661464064, 2507604992, 2439981056}},
{.cache_name = "SR_LRU",
.hashpower = 20,
.req_cnt_true = 113872,
Expand Down
Loading