Skip to content
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

Switch to lower contention ClockCache #7215

Merged
merged 7 commits into from
Jun 25, 2024
Merged

Switch to lower contention ClockCache #7215

merged 7 commits into from
Jun 25, 2024

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented Jun 23, 2024

Changes

  • Switch LruCache to ClockCache
    • Doesn't take any locks in the read path; only marking in bitmap as accessed using Interlocked
    • On Set it takes lock scanning the bitmap advancing a "clock" integer and setting each item as 0, until it comes to one already 0, which it evicts.

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • Yes

If yes, did you write tests?

  • Yes

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Overall well done, but can we remove code duplication, by extracting a shared component that would do the access tracking?

@benaadams benaadams requested a review from LukaszRozmej June 25, 2024 10:40
Copy link
Contributor

@Scooletz Scooletz left a comment

Choose a reason for hiding this comment

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

The Clock bit operations is pretty similar to the BitFilter in Paprika 😅
The clock is simple and easy to reason about.

I believe we can make atomics simpler. Provided comments.

@benaadams benaadams requested a review from Scooletz June 25, 2024 11:11
Copy link
Contributor

@Scooletz Scooletz left a comment

Choose a reason for hiding this comment

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

❤️

@benaadams benaadams merged commit 84cb912 into master Jun 25, 2024
68 checks passed
@benaadams benaadams deleted the clock-cache branch June 25, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants