-
Notifications
You must be signed in to change notification settings - Fork 955
Refactor of LFU/LRU code for modularity #2857
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
Conversation
Signed-off-by: Jim Brunner <[email protected]>
ranshid
left a comment
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.
This is a great refactor @JimB123 !
I could not locate any special issues with the proposed change so gave some small comments. My only concern is that I am not sure how much our test coverage is great when it comes to eviction logic. I guess most of the tests are in maxmemory.tcl which are validated. I think that introducing it now (in early development stage) is probably fine.
| } else { | ||
| val->lru = LRU_CLOCK(); | ||
| } | ||
| val->lru = lrulfu_touch(val->lru); |
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.
why not wrap the touch as an Object API as well?
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.
There's already pretty tight coupling between db.c and object.c. My intent was to clean up the LRU/LFU API (which I did). I wasn't intending to clean up the db/object coupling - that's a bigger task. Given that this was the only place that needed this, and the files are already coupled, I didn't see a reason to create an API for this.
db.c is already directly accessing the lru field when updating in dbSetValue. So there's no point in trying to completely hide it... without further refactor between db/object.
Co-authored-by: Ran Shidlansik <[email protected]> Signed-off-by: Jim Brunner <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2857 +/- ##
============================================
+ Coverage 72.42% 72.43% +0.01%
============================================
Files 128 129 +1
Lines 70300 70502 +202
============================================
+ Hits 50917 51071 +154
- Misses 19383 19431 +48
🚀 New features to boost your workflow:
|
General cleanup on LRU/LFU code. Improve modularity and maintainability.
Specifically:
lrulfu.c, with an API inlrulfu.h. Knowledge of the LRU/LFU implementation was previously spread out acrossdb.c,evict.c,object.c,server.c, andserver.h.lrulfu.cknows about the LRU/LFU algorithms, without knowing about therobj.object.cknows about therobjwithout knowing about the details of the LRU/LFU algorithms.server.lruclock, instead usingserver.unixtime. This also eliminates the periodic need to callmstime()to maintain the lru clock.LFUTimeElapsedfunction (off by 1 after rollover).debug.cwhich would perform LFU modification on an LRU value.