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)
}
pub fn add_un_ref(&self, add: bool) {
if add {
self.ref_count.fetch_add(1, Ordering::Release);
} else {
let previous = self.ref_count.fetch_sub(1, Ordering::Release);
if previous == 0 {
inc_new_counter_info!("accounts_index-deref_from_0", 1);
}
pub fn addref(&self) {
self.ref_count.fetch_add(1, Ordering::Release);
self.set_dirty(true);
}
pub fn unref(&self) {
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);
}
@ -358,11 +359,11 @@ impl<T: IndexValue> ReadAccountMapEntry<T> {
}
pub fn unref(&self) {
self.borrow_owned_entry().add_un_ref(false);
self.borrow_owned_entry().unref();
}
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 {
AccountsIndexScanResult::Unref => {
locked_entry.add_un_ref(false);
locked_entry.unref();
true
}
AccountsIndexScanResult::KeepInMemory => true,

View File

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