From 65614282788031c5b905f39bc9915d6d4e681b7f Mon Sep 17 00:00:00 2001 From: apfitzge Date: Fri, 9 Sep 2022 16:14:55 -0500 Subject: [PATCH] Separate add_un_ref for easier tracing (#27652) --- runtime/src/accounts_index.rs | 23 ++++++++++++----------- runtime/src/in_mem_accounts_index.rs | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index c7d7dce9eb..f81ea7320e 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -273,14 +273,15 @@ impl AccountMapEntryInner { 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 ReadAccountMapEntry { } 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 AccountsIndex { }; cache = match result { AccountsIndexScanResult::Unref => { - locked_entry.add_un_ref(false); + locked_entry.unref(); true } AccountsIndexScanResult::KeepInMemory => true, diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index 477acc640a..e5b8f8ee09 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -437,7 +437,7 @@ impl InMemAccountsIndex { 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 InMemAccountsIndex { reclaim, ); if addref { - current.add_un_ref(true); + current.addref(); } current.set_dirty(true); slot_list.len()