-
Notifications
You must be signed in to change notification settings - Fork 802
Simplify InMemAccountsIndex eviction code #8815
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
Conversation
910aa41 to
95ae604
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8815 +/- ##
=======================================
Coverage 83.2% 83.2%
=======================================
Files 863 863
Lines 373689 373660 -29
=======================================
+ Hits 310984 311022 +38
+ Misses 62705 62638 -67 🚀 New features to boost your workflow:
|
5d5c512 to
d72ef0a
Compare
The PossibleEvictions struct was used to cache FlushScanResult instances, but only one FlushScanResult is ever created at a time (with reset(1) and new(1)). This commit removes the cache and creates the vec locally in flush_scan where it's needed, simplifying the code and reducing memory usage.
FlushScanResult was just a wrapper around a single Vec. This commit removes the wrapper struct and uses Vec<(Pubkey, bool)> directly, further simplifying the code.
d72ef0a to
97ce22f
Compare
Co-authored-by: Brooks <[email protected]>
brooksprumo
left a comment
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.
![]()
| let mut possible_evictions = self.possible_evictions.write().unwrap(); | ||
| possible_evictions.reset(1); | ||
| ) -> Vec<(Pubkey, /*is_dirty*/ bool)> { | ||
| let mut possible_evictions = Vec::new(); |
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.
And now that we always start with a new vec for possible_evictions, we can change gather_possible_evictions() to return the Vec, instead of taking it as an in-out param.
For a followup PR though.
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.
yeah. good idea. will do it in a follow up pr.
Problem
InMemAccountsIndexhas two unnecessary layers of abstraction for managing evictions:PossibleEvictions - A caching struct that always operates with size 1 (
new(1),reset(1),insert(0, ...)). Only oneFlushScanResultis ever created and used at a time, making the caching unnecessary.FlushScanResult - A wrapper struct around a single
Vec<(Pubkey, bool)>with no additional functionality.Summary of change
PossibleEvictionsstruct and its field fromInMemAccountsIndexFlushScanResultstructflush_scanand return it directly asVec<(Pubkey, bool)>gather_possible_evictionsto work with the vec directlyNet result: 79 lines of code removed, simpler and more direct eviction logic.