-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Implementation of Local Cache Algorithm Based on ARC #36376
Implementation of Local Cache Algorithm Based on ARC #36376
Conversation
cc @kssenii |
Something went wrong in testing, but I didn't find out what caused the problem when I submitted the code. Can you help me see what's causing the problem? Or maybe it's due to the test system itself?Thank you ! @kssenii |
The following figure is the comparison effect of the ARC and LRU algorithms in ClickHouse. We run the Q1.1 request of the SSB for four times (it is a small request to simulate the user's small-scale intensive access), and then we run the Q2.1 of the SSB for once (it is a big request, it may scan the whole table, but it will not occur often in real scenarios). After that we run Q1.1 for 4 times . |
f6adee9
to
e31ab5e
Compare
It was a temporary issue with our CI, now should be ok, I just re-run all checks, now they should start properly. |
Let's temporarily turn on your cache algorithm for our CI. Go to |
I may have found a system error caused by assert in the local cache. I need to fix it first and then start subsequent testing. |
615eaf2
to
61a5606
Compare
There was a failure in executing 02240_system_remote_filesystem_cache and 02241_remote_filesystem_cache_on_insert , but after my investigation, I found that it may not be due to the addition of arc algorithm, because I adopted the latest official master branch, which still exists after local retest. I guess it may be that the comparison information is not updated in time after updating the relevant code of local cache. @kssenii |
After using the official master code recomit to test LRU, there will still be the problem of test failure. I think it is really the problem of CI. |
tests/queries/0_stateless/02241_remote_filesystem_cache_on_insert.reference
Outdated
Show resolved
Hide resolved
e3ec259
to
be1288b
Compare
a1c10bd
to
60ce8f1
Compare
499afd2
to
7db7495
Compare
Stateless tests flaky check (address, actions) — Timeout, fail: 0, passed: 150 |
3b28a7e
to
1cb1c72
Compare
b72f4c2
to
9f9f14b
Compare
c78cf55
to
1e63b59
Compare
83c747e
to
9db1023
Compare
return cell.hit_count >= move_threshold; | ||
} | ||
|
||
bool ARCFileCache::tryMoveLowToHigh(const FileSegmentCell & cell, std::lock_guard<std::mutex> & cache_lock) |
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 checked https://www.usenix.org/legacy/events/fast03/tech/full_papers/megiddo/megiddo.pdf and https://dbs.uni-leipzig.de/file/ARC.pdf and it does not really look like ARC described there. To what article did you refer?
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.
Sorry for not recovering in time as I have some trivia in my reality. It looks like this, and I will optimize according to the paper.
@kssenii I looked at some cache algorithm papers and our implementation is probably closer (LRU-K, https://dl.acm.org/doi/pdf/10.1145/170036.170081). The ARC algorithm may not be very suitable for the current situation, because it requires that the size of each cache page is fixed (However, the size of the file segment is not fixed in the implementation of the local cache). We can first implement an LRU-K algorithm (which is still valid for access loads with flushing) and then consider other algorithms (such as the improved ARC algorithm), what do you think? |
Sorry for not replying for some time.
I agree 👍🏻. I'll read the paper you mentioned and review once again. |
sorry for the late reply. I may have to close this PR for the following reasons: |
@KinderRiven there is a work on decoupling caching strategy here: #34651 |
Changelog category (leave one):
Changelog entry:
Compared with the LRU algorithm, the local cache algorithm based on ARC can effectively avoid the problem of cache pool pollution caused by one-time large-scale scanning.
If that commit is accepted, we can support choosing a different local cache algorithm in the config file in subsequent commits.