Move sort timer out of loop (#33448)

move sort timer out of loop

Co-authored-by: HaoranYi <haoran.yi@solana.com>
This commit is contained in:
HaoranYi 2023-09-28 20:10:41 -05:00 committed by GitHub
parent e3cd13e49d
commit 6ea51280dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 8 deletions

View File

@ -7626,16 +7626,11 @@ impl AccountsDb {
}
fn sort_slot_storage_scan(accum: &mut BinnedHashData) -> u64 {
let time = AtomicU64::new(0);
accum.iter_mut().for_each(|items| {
let mut sort_time = Measure::start("sort");
let (_, sort_time) = measure_us!(accum.iter_mut().for_each(|items| {
// sort_by vs unstable because slot and write_version are already in order
items.sort_by(AccountsHasher::compare_two_hash_entries);
sort_time.stop();
time.fetch_add(sort_time.as_us(), Ordering::Relaxed);
});
time.load(Ordering::Relaxed)
}));
sort_time
}
/// normal code path returns the common cache path