metric for accounts index insertion time (#18202) (#18226)

(cherry picked from commit f2a2581259)

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2021-06-25 13:36:29 -05:00
committed by GitHub
parent f82d99b4c2
commit 41179b1282
2 changed files with 52 additions and 37 deletions

View File

@@ -1359,7 +1359,8 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
&self,
slot: Slot,
items: Vec<(&Pubkey, T)>,
) -> Vec<Pubkey> {
) -> (Vec<Pubkey>, u64) {
// returns (duplicate pubkey mask, insertion time us)
let item_len = items.len();
let potentially_new_items = items
.into_iter()
@@ -1375,6 +1376,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
let mut _reclaims = SlotList::new();
let mut duplicate_keys = Vec::with_capacity(item_len / 100); // just an estimate
let mut w_account_maps = self.get_account_maps_write_lock();
let mut insert_time = Measure::start("insert_into_primary_index");
potentially_new_items
.into_iter()
.for_each(|(pubkey, new_item)| {
@@ -1389,7 +1391,8 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
}
});
duplicate_keys
insert_time.stop();
(duplicate_keys, insert_time.as_us())
}
// Updates the given pubkey at the given slot with the new account information.