-
Notifications
You must be signed in to change notification settings - Fork 202
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
Refactor remove_uncleaned_slots to reduce memory consumption #2954
Conversation
72d178b
to
7cc70c2
Compare
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.
Overall look good to me.
Just two suggestions.
Neither of them are blockers. They can be addressed in later PR if we want to.
&self, | ||
max_slot_inclusive: Slot, | ||
) -> Vec<Vec<Pubkey>> { | ||
candidates: &[RwLock<HashMap<Pubkey, CleaningInfo>>], |
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 wonder if there is a case that we don't need filter "up_to_slot"?
If so, maybe we could make max_slot_inclusive Option?
/// returns the minimum slot we encountered | ||
fn insert_pubkey(&self, candidates: &[RwLock<HashMap<Pubkey, CleaningInfo>>], pubkey: Pubkey) { | ||
let index = self.accounts_index.bin_calculator.bin_from_pubkey(&pubkey); | ||
let mut candidates_bin = candidates[index].write().unwrap(); |
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.
nit: maybe we could sort and group the pubkeys by bins and insert all pubkeys to the same bin at once.
This will save the repeated costs of lock and unlock of the same bin, also we may have better cache locality.
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’ll make a follow-up PR. Thank you.
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 extraneous allocation is a strict improvement over the current code.
@jeffwashington should I wait for your review, or ok to merge? |
Problem
Cleaning algorithm creates many temporary data sets that consume significant amount of heap, increasing memory requirements of the validator.
Summary of Changes
Avoid making another temporary container of pubkeys that are candidates for cleaning.
This change reduces the used heap memory by 14% on a sample snapshot cleaning from 166,737,546,218 to 143,515,886,322 bytes.
Also collapse two small functions where the first is the only caller of the second into a single function, and remove a unit test that is almost a duplicate of another existing test that exercises the first of the functions.