-
Notifications
You must be signed in to change notification settings - Fork 239
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
Replace purges_old_accounts by a boolean field in CleaningInfo #2566
Conversation
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.
Removing the separate purges_old_accounts
vec in favor of tracking purgeables within the candidates info looks good to me.
let reclaim_vecs = candidates | ||
.par_iter() | ||
.filter_map(|candidates_bin| { |
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.
:chefs-kiss:
accounts-db/src/accounts_db.rs
Outdated
max_clean_root_inclusive: Option<Slot>, | ||
ancient_account_cleans: &AtomicU64, | ||
epoch_schedule: &EpochSchedule, | ||
) -> (ReclaimResult, PubkeysRemovedFromAccountsIndex) { | ||
let pubkeys_removed_from_accounts_index = HashSet::default(); | ||
if purges.is_empty() { | ||
// return early if there are no old accounts to purge | ||
if !candidates |
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.
this could be very expensive and I think will scan all bins every time. I'd prefer to see a bool set at the caller that knows if there were any should_purge
accounts. You could set a local atomic in the index scan in the calling fn if any account is set to should_purge
. That could be passed to this fn or this fn could just assume that there is at least one should_purge
entry if it is called with candidates
. This first check is really just a cya to make sure that we know the behavior if there are no should_purge
accounts. So, we could probably get rid of it in any case if we are careful of what the resulting behavior would be. I acknowledge that this code is a correct drop in replacement for purges
before.
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.
I moved the check to the caller and used an atomic bool to record whether any purgeable candidate exists.
Yes! I love this. ty! |
accounts-db/src/accounts_db.rs
Outdated
let mut not_found_on_fork = 0; | ||
let mut missing = 0; | ||
let mut useful = 0; | ||
let mut exist_purgeable_accounts_local = false; |
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.
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.
I removed the check. From what I can tell the function should return empty ReclaimResult and an empty HashSet for pubkeys_removed_from_accounts_index if there were no purgeable 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.
i read through it as well. it appears as if it will do the right thing.
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.
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.
We added 4 bytes (a |
yep, I thought about the 4 bytes. i expected a different curve. doesn't mean this is right or wrong - just surprising. |
I think this is a good idea anyway. |
do this separately. this pr is ready imo |
unless we can think of a clever way to store the bit in what we're already storing. |
Let's merge this for now, and I'll think how it might be improved. |
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.
I love the idea.
lgtm!
…xyz#2566) * Replace purges_old_accounts by a boolean field in CleaningInfo * comments * Move check for purgeable accounts existence to caller * Corrections to Atomic * correction. * Remove checks for no-existent purge old accounts
Problem
Cleaning empty accounts from accounts index uses a lot of memory by copying large amounts of data.
Summary of Changes
Further reduce memory use in
clean_accounts
by keeping information about cleaning candidates in a single data structure instead of copying it to multiple containers. This PR removespurges_old_accounts
vector and replaces it with a boolean fieldshould_purge
inCleaningInfo
structure.