Separate add_un_ref for easier tracing (#27652)

This commit is contained in:
apfitzge 2022-09-09 16:14:55 -05:00 committed by GitHub
parent e42a39024d
commit 6561428278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -273,14 +273,15 @@ impl<T: IndexValue> AccountMapEntryInner<T> {
self.ref_count.load(Ordering::Acquire) self.ref_count.load(Ordering::Acquire)
} }
pub fn add_un_ref(&self, add: bool) { pub fn addref(&self) {
if add { self.ref_count.fetch_add(1, Ordering::Release);
self.ref_count.fetch_add(1, Ordering::Release); self.set_dirty(true);
} else { }
let previous = self.ref_count.fetch_sub(1, Ordering::Release);
if previous == 0 { pub fn unref(&self) {
inc_new_counter_info!("accounts_index-deref_from_0", 1); let previous = self.ref_count.fetch_sub(1, Ordering::Release);
} if previous == 0 {
inc_new_counter_info!("accounts_index-deref_from_0", 1);
} }
self.set_dirty(true); self.set_dirty(true);
} }
@ -358,11 +359,11 @@ impl<T: IndexValue> ReadAccountMapEntry<T> {
} }
pub fn unref(&self) { pub fn unref(&self) {
self.borrow_owned_entry().add_un_ref(false); self.borrow_owned_entry().unref();
} }
pub fn addref(&self) { pub fn addref(&self) {
self.borrow_owned_entry().add_un_ref(true); self.borrow_owned_entry().addref();
} }
} }
@ -1386,7 +1387,7 @@ impl<T: IndexValue> AccountsIndex<T> {
}; };
cache = match result { cache = match result {
AccountsIndexScanResult::Unref => { AccountsIndexScanResult::Unref => {
locked_entry.add_un_ref(false); locked_entry.unref();
true true
} }
AccountsIndexScanResult::KeepInMemory => true, AccountsIndexScanResult::KeepInMemory => true,

View File

@ -437,7 +437,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
pub fn unref(&self, pubkey: &Pubkey) { pub fn unref(&self, pubkey: &Pubkey) {
self.get_internal(pubkey, |entry| { self.get_internal(pubkey, |entry| {
if let Some(entry) = entry { if let Some(entry) = entry {
entry.add_un_ref(false) entry.unref();
} }
(true, ()) (true, ())
}) })
@ -557,7 +557,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
reclaim, reclaim,
); );
if addref { if addref {
current.add_un_ref(true); current.addref();
} }
current.set_dirty(true); current.set_dirty(true);
slot_list.len() slot_list.len()