-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update max freq on insertion, change debug invariant #130
Conversation
@@ -216,6 +216,7 @@ static cache_obj_t *LFUDA_insert(cache_t *cache, const request_t *req) { | |||
memset(new_node, 0, sizeof(freq_node_t)); | |||
new_node->freq = cache_obj->lfu.freq; | |||
g_hash_table_insert(params->freq_map, key, new_node); | |||
params->max_freq = params->max_freq < cache_obj->lfu.freq ? cache_obj->lfu.freq : params->max_freq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update max_freq if a new node is added. Current behaviour only updates max_freq upon a cache hit.
Result of execution: `./bin/cachesim ../_build/data.csv csv lfuda 0.8,0.9 -t "time-col=1,obj-id-col=3,obj-size-col=4,delimiter=,,obj-id-is-num=0" ../_build/data.csv LFUDA cache size 1MiB, 9 req, miss ratio 1.0000, byte miss ratio 1.0000 |
@@ -353,7 +354,8 @@ static void update_min_freq(LFUDA_params_t *params) { | |||
break; | |||
} | |||
} | |||
DEBUG_ASSERT(params->min_freq > old_min_freq); | |||
// If cache is empty, min_freq will be unchanged. | |||
DEBUG_ASSERT(params->min_freq >= old_min_freq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the assertion to include equality too (params->min_freq >= old_min_freq).
This is because on a cache with only 1 item gets evicted, the min_freq will stay unchanged.
For example we have 1 item in cache like so, with current min freq = 2:
Freq 2: Object A
If this object A gets evicted, min_freq should will stay at 2, thus the assert failed.
Note: LFU will also trigger this debug assertion. LFU.c solves this by resetting the min_freq directly to 0 without calling the function
Thank you! |
Hello! This is my attempt to fix the issue.
The problem arises because:
I have implemented small fixes for this, and have tried to verify that it works.
Thanks!