-
Notifications
You must be signed in to change notification settings - Fork 255
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
add uncleaned roots when we shrink away non-zero lamport accounts #2824
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2038,6 +2038,7 @@ pub struct ShrinkStats { | |
accounts_loaded: AtomicU64, | ||
purged_zero_lamports: AtomicU64, | ||
accounts_not_found_in_index: AtomicU64, | ||
adding_slots_to_clean: AtomicU64, | ||
} | ||
|
||
impl ShrinkStats { | ||
|
@@ -2156,6 +2157,11 @@ impl ShrinkStats { | |
self.accounts_not_found_in_index.swap(0, Ordering::Relaxed), | ||
i64 | ||
), | ||
( | ||
"adding_slots_to_clean", | ||
self.adding_slots_to_clean.swap(0, Ordering::Relaxed), | ||
i64 | ||
), | ||
); | ||
} | ||
} | ||
|
@@ -2384,6 +2390,13 @@ impl ShrinkAncientStats { | |
.swap(0, Ordering::Relaxed), | ||
i64 | ||
), | ||
( | ||
"adding_slots_to_clean", | ||
self.shrink_stats | ||
.adding_slots_to_clean | ||
.swap(0, Ordering::Relaxed), | ||
i64 | ||
), | ||
); | ||
} | ||
} | ||
|
@@ -3960,6 +3973,7 @@ impl AccountsDb { | |
let mut alive = 0; | ||
let mut dead = 0; | ||
let mut index = 0; | ||
let mut adding_slots_to_clean = 0; | ||
let mut index_scan_returned_some_count = 0; | ||
let mut index_scan_returned_none_count = 0; | ||
let mut all_are_zero_lamports = true; | ||
|
@@ -4006,6 +4020,18 @@ impl AccountsDb { | |
unrefed_pubkeys.push(pubkey); | ||
result = AccountsIndexScanResult::Unref; | ||
dead += 1; | ||
|
||
// If we are marking something dead, and the only remaining alive account is zero lamport, then make that zero lamport slot ready to be cleaned. | ||
// If that slot happens to only contain zero lamport accounts, the whole slot will go away | ||
if slot_list.len() == 1 // should we also check for ref counts here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about not checking the slot list len, but instead seeing if the latest slot list entry's account info is zero lamports? (Maybe we'd also need to bound the latest entry to be a storage and not a cached entry?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should check for ref count. However, we should check after we have unref'd this one. There can be 3 refs, 1 alive that is zero lamport. Each time we unref a pubkey in shrink where the alive one is dead, we should check if refcount has become 1. If so, we know this account can be marked dead and shrunk or entire slot cleaned. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, see: |
||
&& slot_list | ||
.iter() | ||
.all(|(_slot, acct_info)| acct_info.is_zero_lamport()) | ||
{ | ||
adding_slots_to_clean += 1; | ||
self.accounts_index | ||
.add_uncleaned_roots(slot_list.iter().map(|(slot, _)| *slot)); | ||
} | ||
} else { | ||
do_populate_accounts_for_shrink(ref_count, slot_list); | ||
} | ||
|
@@ -4036,6 +4062,9 @@ impl AccountsDb { | |
.fetch_add(index_scan_returned_none_count, Ordering::Relaxed); | ||
stats.alive_accounts.fetch_add(alive, Ordering::Relaxed); | ||
stats.dead_accounts.fetch_add(dead, Ordering::Relaxed); | ||
stats | ||
.adding_slots_to_clean | ||
.fetch_add(adding_slots_to_clean, Ordering::Relaxed); | ||
|
||
LoadAccountsIndexForShrink { | ||
alive_accounts, | ||
|
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.
Is it possible that the slot_list contains more than one zero lamport accounts?
Can we relax the requirement for slot_list.len() ==1?