From 9b042fed3056b9696b3f2bd1fa02776f5dba21d3 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Thu, 14 Oct 2021 08:36:53 -0500 Subject: [PATCH] AcctIdx: support unref first class for perf (#20638) --- runtime/src/accounts_index.rs | 5 ++--- runtime/src/in_mem_accounts_index.rs | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 5bec058d13..b058e194d2 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1637,9 +1637,8 @@ impl AccountsIndex { } pub fn unref_from_storage(&self, pubkey: &Pubkey) { - if let Some(locked_entry) = self.get_account_read_entry(pubkey) { - locked_entry.unref(); - } + let map = &self.account_maps[self.bin_calculator.bin_from_pubkey(pubkey)]; + map.read().unwrap().unref(pubkey) } pub fn ref_count_from_storage(&self, pubkey: &Pubkey) -> RefCount { diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index c91c48a17b..b3a25345f7 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -290,6 +290,10 @@ impl InMemAccountsIndex { }) } + pub fn unref(&self, pubkey: &Pubkey) { + self.get_internal(pubkey, |entry| entry.map(|entry| entry.add_un_ref(false))); + } + pub fn upsert( &self, pubkey: &Pubkey,