Skip to content

Fix bugs in Simple Cache #263

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

raakella1
Copy link
Contributor

@raakella1 raakella1 commented Mar 30, 2025

  • Fix the condition to evict keys in lru_evictor
  • Remove the key from hashmap after removing from the evictor.
  • Add a test case to trigger eviction using multiple threads.

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 76.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 60.79%. Comparing base (370c772) to head (816b94a).
Report is 27 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
- Coverage   64.29%   60.79%   -3.51%     
==========================================
  Files          72       74       +2     
  Lines        4406     4828     +422     
  Branches      555      654      +99     
==========================================
+ Hits         2833     2935     +102     
- Misses       1327     1634     +307     
- Partials      246      259      +13     
Components Coverage Δ
AuthManager 77.77% <ø> (ø)
Cache 37.45% <76.00%> (+7.51%) ⬆️
FDS 71.19% <100.00%> (+0.07%) ⬆️
FileWatcher 56.25% <ø> (ø)
Flip 65.34% <ø> (ø)
gRPC 76.04% <64.70%> (-1.01%) ⬇️
Logging 15.46% <3.69%> (-14.72%) ⬇️
Metrics 80.54% <ø> (+0.33%) ⬆️
Options 100.00% <ø> (ø)
Setting 56.79% <ø> (ø)
StatusObject 73.83% <ø> (ø)
Utility 83.47% <100.00%> (+0.75%) ⬆️
Version 95.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raakella1 raakella1 force-pushed the simple_cache branch 3 times, most recently from b3ff5d7 to d3ca31b Compare April 17, 2025 22:22
@@ -58,13 +58,19 @@ bool LRUEvictor::LRUPartition::add_record(CacheRecord &record) {

void LRUEvictor::LRUPartition::remove_record(CacheRecord &record) {
std::unique_lock guard{m_list_guard};
if (!record.m_member_hook.is_linked()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put some comment here, what does this if check and why should we return here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However why cache would remove a record that is not present, shouldn't we crash to catch the bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking Debug assert and error log? It would not affect functionality in production, just a size mismatch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is this is here for a reason right? Or is it just a defend check? If we are seeing this assert in our test, it means there is probably some race we don't know yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was not there before, I added it because I hit the crash due to a bug in my implementation that was hit during the unit test. I added this now so that we will know where it failed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a defend check, we are not hitting it now in the tests

@raakella1
Copy link
Contributor Author

@yamingk I added more comments to the code at several places you suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants