-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
uses atomics for read-only account cache entry index #32518
uses atomics for read-only account cache entry index #32518
Conversation
Codecov Report
@@ Coverage Diff @@
## master #32518 +/- ##
=========================================
- Coverage 82.0% 82.0% -0.1%
=========================================
Files 785 785
Lines 211192 211204 +12
=========================================
Hits 173200 173200
- Misses 37992 38004 +12 |
@behzadnouri I'm happy with this change. It does allow us to get rid of the write lock. Along with the idea of only updating the lru once per interval instead of every time, we can eliminate the contention on the lru queue as well. This avoids us having to modify |
"updating the lru once per interval instead of every time" What is blocking to add the new |
It's externally owned and not on a schedule we control. I have not heard anything on my draft pr yet. I am unclear of their goals or requirements for getting this in. In the interim, I have a pr for discussion to use the subset of the code we need and add |
I'm personally comfortable with lrus of caches being heuristic. Maybe this heuristic can help us come up with a better idea or heuristic. The system has to be correct and tolerant whether an account is in the read only cache or not. We'd know that a heuristic is bad if the cache hit rate is low. Otherwise, load will be faster and cache hit rate should be similarly high. Hardcoding the owner being vote account is a bridge too far for me, even though that knocks out the biggest offender ;-) We could also always update the timestamp, but then when we look at the oldest items in lru, we could get rid of the ones at the end that have the oldest timestamp. So, even if we didn't update lru list, we'd still effectively get rid of the oldest items, while only searching a small set of entries. That would get our heuristic to an even closer match to reality. |
Actually, at eviction time (which is already rare and could also be done in the bg) all we have to do is search backwards in lru for all entries with timestamp relative to oldest lru item < lru update time (100ms, 10ms, whatever). There will be very few items to scan. Then, we can exactly hit the oldest items for eviction with minimal effort/time. But all this is overkill in practice, I think. |
addf2c4
to
d67a383
Compare
Using atomics for entry indices allows load to use self.cache.get instead of get_mut which reduces lock contention on the respective dash-map shard.
d67a383
to
57ff271
Compare
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.
lgtm. ty. Good building block to get rid of write lock.
Problem
Improve loads on read-only account cache.
Summary of Changes
ReadOnlyAccountsCache::load
no longer needs a mutable entry.