rename get_account_maps_read_lock to get_bin since we don't use a loc… (#27543)

rename get_account_maps_read_lock to get_bin since we don't ues a lock anymore
This commit is contained in:
Jeff Washington (jwash) 2022-09-06 07:22:55 -07:00 committed by GitHub
parent f90e70ff5a
commit ed132e75a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -8627,7 +8627,7 @@ impl AccountsDb {
let mut lookup_time = Measure::start("lookup_time"); let mut lookup_time = Measure::start("lookup_time");
for account in accounts_map.into_iter() { for account in accounts_map.into_iter() {
let (key, account_info) = account; let (key, account_info) = account;
let lock = self.accounts_index.get_account_maps_read_lock(&key); let lock = self.accounts_index.get_bin(&key);
let x = lock.get(&key).unwrap(); let x = lock.get(&key).unwrap();
let sl = x.slot_list.read().unwrap(); let sl = x.slot_list.read().unwrap();
let mut count = 0; let mut count = 0;

View File

@ -1111,7 +1111,7 @@ impl<T: IndexValue> AccountsIndex<T> {
} }
pub fn get_account_read_entry(&self, pubkey: &Pubkey) -> Option<ReadAccountMapEntry<T>> { pub fn get_account_read_entry(&self, pubkey: &Pubkey) -> Option<ReadAccountMapEntry<T>> {
let lock = self.get_account_maps_read_lock(pubkey); let lock = self.get_bin(pubkey);
self.get_account_read_entry_with_lock(pubkey, &lock) self.get_account_read_entry_with_lock(pubkey, &lock)
} }
@ -1129,7 +1129,7 @@ impl<T: IndexValue> AccountsIndex<T> {
pubkey: &Pubkey, pubkey: &Pubkey,
user: impl for<'a> FnOnce(&mut RwLockWriteGuard<'a, SlotList<T>>) -> RT, user: impl for<'a> FnOnce(&mut RwLockWriteGuard<'a, SlotList<T>>) -> RT,
) -> Option<RT> { ) -> Option<RT> {
let read_lock = self.get_account_maps_read_lock(pubkey); let read_lock = self.get_bin(pubkey);
read_lock.slot_list_mut(pubkey, user) read_lock.slot_list_mut(pubkey, user)
} }
@ -1140,7 +1140,7 @@ impl<T: IndexValue> AccountsIndex<T> {
) { ) {
if !dead_keys.is_empty() { if !dead_keys.is_empty() {
for key in dead_keys.iter() { for key in dead_keys.iter() {
let w_index = self.get_account_maps_read_lock(key); let w_index = self.get_bin(key);
if w_index.remove_if_slot_list_empty(**key) { if w_index.remove_if_slot_list_empty(**key) {
// Note it's only safe to remove all the entries for this key // Note it's only safe to remove all the entries for this key
// because we have the lock for this key's entry in the AccountsIndex, // because we have the lock for this key's entry in the AccountsIndex,
@ -1407,7 +1407,7 @@ impl<T: IndexValue> AccountsIndex<T> {
ancestors: Option<&Ancestors>, ancestors: Option<&Ancestors>,
max_root: Option<Slot>, max_root: Option<Slot>,
) -> AccountIndexGetResult<T> { ) -> AccountIndexGetResult<T> {
let read_lock = self.get_account_maps_read_lock(pubkey); let read_lock = self.get_bin(pubkey);
let account = read_lock let account = read_lock
.get(pubkey) .get(pubkey)
.map(ReadAccountMapEntry::from_account_map_entry); .map(ReadAccountMapEntry::from_account_map_entry);
@ -1536,7 +1536,7 @@ impl<T: IndexValue> AccountsIndex<T> {
); );
} }
pub(crate) fn get_account_maps_read_lock(&self, pubkey: &Pubkey) -> AccountMapsReadLock<T> { pub(crate) fn get_bin(&self, pubkey: &Pubkey) -> AccountMapsReadLock<T> {
&self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)] &self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)]
} }
@ -1662,19 +1662,19 @@ impl<T: IndexValue> AccountsIndex<T> {
&self.storage.storage, &self.storage.storage,
store_raw, store_raw,
); );
let map = self.get_account_maps_read_lock(pubkey); let map = self.get_bin(pubkey);
map.upsert(pubkey, new_item, Some(old_slot), reclaims, reclaim); map.upsert(pubkey, new_item, Some(old_slot), reclaims, reclaim);
self.update_secondary_indexes(pubkey, account, account_indexes); self.update_secondary_indexes(pubkey, account, account_indexes);
} }
pub fn unref_from_storage(&self, pubkey: &Pubkey) { pub fn unref_from_storage(&self, pubkey: &Pubkey) {
let map = self.get_account_maps_read_lock(pubkey); let map = self.get_bin(pubkey);
map.unref(pubkey) map.unref(pubkey)
} }
pub fn ref_count_from_storage(&self, pubkey: &Pubkey) -> RefCount { pub fn ref_count_from_storage(&self, pubkey: &Pubkey) -> RefCount {
let map = self.get_account_maps_read_lock(pubkey); let map = self.get_bin(pubkey);
map.get_internal(pubkey, |entry| { map.get_internal(pubkey, |entry| {
( (
false, false,
@ -1751,7 +1751,7 @@ impl<T: IndexValue> AccountsIndex<T> {
// locked and inserted the pubkey in-between when `is_slot_list_empty=true` and the call to // locked and inserted the pubkey in-between when `is_slot_list_empty=true` and the call to
// remove() below. // remove() below.
if is_slot_list_empty { if is_slot_list_empty {
let w_maps = self.get_account_maps_read_lock(pubkey); let w_maps = self.get_bin(pubkey);
w_maps.remove_if_slot_list_empty(*pubkey); w_maps.remove_if_slot_list_empty(*pubkey);
} }
} }
@ -2641,7 +2641,7 @@ pub mod tests {
for lock in &[false, true] { for lock in &[false, true] {
let read_lock = if *lock { let read_lock = if *lock {
Some(index.get_account_maps_read_lock(&key)) Some(index.get_bin(&key))
} else { } else {
None None
}; };
@ -2696,7 +2696,7 @@ pub mod tests {
assert_eq!((slot, account_info), new_entry.clone().into()); assert_eq!((slot, account_info), new_entry.clone().into());
assert_eq!(0, account_maps_stats_len(&index)); assert_eq!(0, account_maps_stats_len(&index));
let r_account_maps = index.get_account_maps_read_lock(&key.pubkey()); let r_account_maps = index.get_bin(&key.pubkey());
r_account_maps.upsert( r_account_maps.upsert(
&key.pubkey(), &key.pubkey(),
new_entry, new_entry,