lru: atomic refcount, unlock release path#111
Merged
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (67.96%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 55.56% 55.77% +0.21%
==========================================
Files 49 49
Lines 6875 6890 +15
Branches 1227 1232 +5
==========================================
+ Hits 3820 3843 +23
- Misses 2570 2572 +2
+ Partials 485 475 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced May 19, 2026
a89bc8b to
8002a77
Compare
badd06a to
dafe8b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the per-entry refcount atomic and drop the cache mutex from the release path. Acquire still takes the mutex — incrementing from zero has to be serialized against the eviction scan, which reads refcounts to decide what's safe to evict.
Why
The refcount is a per-entry counter. It was under the cache mutex only because the field lived inside the entry struct, not because the value needed that lock.
Results
Not a lot of measured performance change on my laptop. The change is still worth landing for cleaner refcount semantics and for the new contention test that exercises the release path under concurrency, but don't expect this workload to get faster.
Key file
src/util/lru.c— refcount, acquire/release, eviction reads.Closes #108.