Skip to content

Conversation

@HaoranYi
Copy link

@HaoranYi HaoranYi commented Oct 31, 2025

Problem

InMemAccountsIndex has two unnecessary layers of abstraction for managing evictions:

  1. PossibleEvictions - A caching struct that always operates with size 1 (new(1), reset(1), insert(0, ...)). Only one FlushScanResult is ever created and used at a time, making the caching unnecessary.

  2. FlushScanResult - A wrapper struct around a single Vec<(Pubkey, bool)> with no additional functionality.

Summary of change

  • Remove PossibleEvictions struct and its field from InMemAccountsIndex
  • Remove FlushScanResult struct
  • Create the evictions vec locally in flush_scan and return it directly as Vec<(Pubkey, bool)>
  • Update gather_possible_evictions to work with the vec directly

Net result: 79 lines of code removed, simpler and more direct eviction logic.

@HaoranYi HaoranYi marked this pull request as draft October 31, 2025 18:44
@HaoranYi HaoranYi changed the title Remove unnecessary eviction wrappers from InMemAccountsIndex Simplify InMemAccountsIndex eviction code Oct 31, 2025
@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.2%. Comparing base (e1634f7) to head (9d9b320).
⚠️ Report is 5 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HaoranYi HaoranYi marked this pull request as ready for review November 4, 2025 16:06
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.
roryharr
roryharr previously approved these changes Nov 4, 2025
Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

let mut possible_evictions = self.possible_evictions.write().unwrap();
possible_evictions.reset(1);
) -> Vec<(Pubkey, /*is_dirty*/ bool)> {
let mut possible_evictions = Vec::new();

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.

Copy link
Author

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.

@HaoranYi HaoranYi added this pull request to the merge queue Nov 5, 2025
Merged via the queue into master with commit 97c34d3 Nov 5, 2025
44 checks passed
@HaoranYi HaoranYi deleted the possible_eviction branch November 5, 2025 17:03
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