accounts hash sort_slot_storage_scan sorts in place (#32810)
This commit is contained in:
parent
e0de0685cb
commit
9212ac347c
|
@ -2406,10 +2406,10 @@ impl<'a> AppendVecScan for ScanState<'a> {
|
||||||
self.init_accum(self.range);
|
self.init_accum(self.range);
|
||||||
self.accum[self.pubkey_to_bin_index].push(source_item);
|
self.accum[self.pubkey_to_bin_index].push(source_item);
|
||||||
}
|
}
|
||||||
fn scanning_complete(self) -> BinnedHashData {
|
fn scanning_complete(mut self) -> BinnedHashData {
|
||||||
let (result, timing) = AccountsDb::sort_slot_storage_scan(self.accum);
|
let timing = AccountsDb::sort_slot_storage_scan(&mut self.accum);
|
||||||
self.sort_time.fetch_add(timing, Ordering::Relaxed);
|
self.sort_time.fetch_add(timing, Ordering::Relaxed);
|
||||||
result
|
self.accum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7566,24 +7566,17 @@ impl AccountsDb {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sort_slot_storage_scan(accum: BinnedHashData) -> (BinnedHashData, u64) {
|
fn sort_slot_storage_scan(accum: &mut BinnedHashData) -> u64 {
|
||||||
let time = AtomicU64::new(0);
|
let time = AtomicU64::new(0);
|
||||||
(
|
accum.iter_mut().for_each(|items| {
|
||||||
accum
|
|
||||||
.into_iter()
|
|
||||||
.map(|mut items| {
|
|
||||||
let mut sort_time = Measure::start("sort");
|
let mut sort_time = Measure::start("sort");
|
||||||
{
|
|
||||||
// sort_by vs unstable because slot and write_version are already in order
|
// sort_by vs unstable because slot and write_version are already in order
|
||||||
items.sort_by(AccountsHasher::compare_two_hash_entries);
|
items.sort_by(AccountsHasher::compare_two_hash_entries);
|
||||||
}
|
|
||||||
sort_time.stop();
|
sort_time.stop();
|
||||||
time.fetch_add(sort_time.as_us(), Ordering::Relaxed);
|
time.fetch_add(sort_time.as_us(), Ordering::Relaxed);
|
||||||
items
|
});
|
||||||
})
|
|
||||||
.collect(),
|
time.load(Ordering::Relaxed)
|
||||||
time.load(Ordering::Relaxed),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// normal code path returns the common cache path
|
/// normal code path returns the common cache path
|
||||||
|
|
Loading…
Reference in New Issue