Skip to content

Make flushing of unrooted slots explicit#9960

Merged
roryharr merged 5 commits intoanza-xyz:masterfrom
roryharr:explicit_flush_unrooted_slot
Jan 14, 2026
Merged

Make flushing of unrooted slots explicit#9960
roryharr merged 5 commits intoanza-xyz:masterfrom
roryharr:explicit_flush_unrooted_slot

Conversation

@roryharr
Copy link
Copy Markdown

@roryharr roryharr commented Jan 12, 2026

Problem

Flushing unrooted slots should only be done when the accounts cache exceeds the expected size. Make flushing of unrooted slots explicit in general to avoid unintentionally flushing unrooted slots

Summary of Changes

  • Added new function flush_unrooted_cache_slot
  • Switched all callers that are intending to flush unrooted cacheslots to call flush_unrooted_cache_slot
  • Added assert to flush_cache_slot that slots are rooted.
  • removed flush_slot_cache

Note:
This is currently relevant as some of the expectations around clean will need to change as the handling of zero lamport accounts only accessed in a single slot (aka ephemeral accounts) will change.

Fixes #

Comment thread accounts-db/src/accounts_db/tests.rs Outdated
Comment thread accounts-db/src/accounts_db.rs Outdated
let mut flush_stats = FlushStats::default();
old_slots.into_iter().for_each(|old_slot| {
// Don't flush slots that are known to be unrooted
// Slots <= max_flushed_root can never become roots later (any unrooted slot that
Copy link
Copy Markdown
Author

@roryharr roryharr Jan 12, 2026

Choose a reason for hiding this comment

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

This comment was incredibly confusing to me (and has been everytime i've looked at this function). Updated.

Comment thread accounts-db/src/accounts_db.rs Outdated

pub fn flush_accounts_cache_slot_for_tests(&self, slot: Slot) {
self.flush_slot_cache(slot);
assert!(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Originally I retained flush_slot_cache and added the root assert, but it was only being used in flush_accounts_cache_slot_for_tests which lead to unused function errors. Decided this was the cleanest way to fix it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Might be useful to look at each commit individually.

Comment thread accounts-db/src/accounts_db.rs Outdated
fn flush_slot_cache(&self, slot: Slot) -> Option<FlushStats> {
/// Flushes an unrooted slot from the write cache to storage to free up memory
#[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))]
fn flush_unrooted_cache_slot(&self, slot: Slot) -> Option<FlushStats> {
Copy link
Copy Markdown
Author

@roryharr roryharr Jan 12, 2026

Choose a reason for hiding this comment

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

This diff looks a little weird. There are two changes

  1. flush_unrooted_cache_slot
  2. Removing flush_slot_cache

.contains(&slot),
"slot: {slot}"
);
self.flush_slot_cache_with_clean(slot, None::<&mut fn(&_) -> bool>, None);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This doesn't clean because should_clean is None. Cleaning is the desired behaviour (since it is the default behaviour), but I will handle that in another PR.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.5%. Comparing base (552674f) to head (ce549d2).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #9960     +/-   ##
=========================================
- Coverage    82.5%    82.5%   -0.1%     
=========================================
  Files         844      844             
  Lines      316472   316485     +13     
=========================================
+ Hits       261309   261314      +5     
- Misses      55163    55171      +8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roryharr roryharr requested a review from brooksprumo January 12, 2026 23:01
@roryharr roryharr marked this pull request as ready for review January 12, 2026 23:01
Copy link
Copy Markdown

@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.

Looks good overall.

Comment thread accounts-db/src/accounts_db.rs
Comment thread accounts-db/src/accounts_db.rs Outdated
@roryharr roryharr force-pushed the explicit_flush_unrooted_slot branch from 9a5629d to f52212c Compare January 13, 2026 23:30
Copy link
Copy Markdown

@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.

These items are still open imo:

  1. #9960 (comment)

  2. From #9960 (comment):

  1. Can we put the assert in here (vs the test fn) to ensure slot is unrooted?

Removing changes to tests that are not using new function
@roryharr roryharr requested a review from brooksprumo January 14, 2026 19:26
Copy link
Copy Markdown

@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:

@roryharr roryharr added this pull request to the merge queue Jan 14, 2026
Merged via the queue into anza-xyz:master with commit a79a700 Jan 14, 2026
47 checks passed
@roryharr roryharr deleted the explicit_flush_unrooted_slot branch January 14, 2026 23:06
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.

3 participants