From a5e055f56c265954f44cb5b7f7cc3ed7900f311c Mon Sep 17 00:00:00 2001 From: vovkman Date: Thu, 19 Oct 2023 12:57:49 -0700 Subject: [PATCH 1/3] Remove RWLock from EntryNotifier because it causes perf degradation when entry notifications are enabled on geyser --- core/src/validator.rs | 4 ++-- geyser-plugin-manager/src/geyser_plugin_service.rs | 8 ++++---- ledger/src/entry_notifier_interface.rs | 2 +- ledger/src/entry_notifier_service.rs | 11 ++++------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 3075fb5261a180..3dfcdb411847de 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -58,7 +58,7 @@ use { }, blockstore_options::{BlockstoreOptions, BlockstoreRecoveryMode, LedgerColumnOptions}, blockstore_processor::{self, TransactionStatusSender}, - entry_notifier_interface::EntryNotifierLock, + entry_notifier_interface::EntryNotifierArc, entry_notifier_service::{EntryNotifierSender, EntryNotifierService}, leader_schedule::FixedSchedule, leader_schedule_cache::LeaderScheduleCache, @@ -1687,7 +1687,7 @@ fn load_blockstore( start_progress: &Arc>, accounts_update_notifier: Option, transaction_notifier: Option, - entry_notifier: Option, + entry_notifier: Option, poh_timing_point_sender: Option, ) -> Result< ( diff --git a/geyser-plugin-manager/src/geyser_plugin_service.rs b/geyser-plugin-manager/src/geyser_plugin_service.rs index b8f9db49102dc7..fc8c67c10e6db0 100644 --- a/geyser-plugin-manager/src/geyser_plugin_service.rs +++ b/geyser-plugin-manager/src/geyser_plugin_service.rs @@ -12,7 +12,7 @@ use { crossbeam_channel::Receiver, log::*, solana_accounts_db::accounts_update_notifier_interface::AccountsUpdateNotifier, - solana_ledger::entry_notifier_interface::EntryNotifierLock, + solana_ledger::entry_notifier_interface::EntryNotifierArc, solana_rpc::{ optimistically_confirmed_bank_tracker::SlotNotification, transaction_notifier_interface::TransactionNotifierLock, @@ -35,7 +35,7 @@ pub struct GeyserPluginService { plugin_manager: Arc>, accounts_update_notifier: Option, transaction_notifier: Option, - entry_notifier: Option, + entry_notifier: Option, block_metadata_notifier: Option, } @@ -100,7 +100,7 @@ impl GeyserPluginService { None }; - let entry_notifier: Option = if entry_notifications_enabled { + let entry_notifier: Option = if entry_notifications_enabled { let entry_notifier = EntryNotifierImpl::new(plugin_manager.clone()); Some(Arc::new(RwLock::new(entry_notifier))) } else { @@ -164,7 +164,7 @@ impl GeyserPluginService { self.transaction_notifier.clone() } - pub fn get_entry_notifier(&self) -> Option { + pub fn get_entry_notifier(&self) -> Option { self.entry_notifier.clone() } diff --git a/ledger/src/entry_notifier_interface.rs b/ledger/src/entry_notifier_interface.rs index de523fc979ab01..692b55a26767cd 100644 --- a/ledger/src/entry_notifier_interface.rs +++ b/ledger/src/entry_notifier_interface.rs @@ -8,4 +8,4 @@ pub trait EntryNotifier { fn notify_entry(&self, slot: Slot, index: usize, entry: &EntrySummary); } -pub type EntryNotifierLock = Arc>; +pub type EntryNotifierArc = Arc; diff --git a/ledger/src/entry_notifier_service.rs b/ledger/src/entry_notifier_service.rs index 5e108c94e80578..ec7eae0bc75723 100644 --- a/ledger/src/entry_notifier_service.rs +++ b/ledger/src/entry_notifier_service.rs @@ -1,5 +1,5 @@ use { - crate::entry_notifier_interface::EntryNotifierLock, + crate::entry_notifier_interface::EntryNotifierArc, crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender}, solana_entry::entry::EntrySummary, solana_sdk::clock::Slot, @@ -28,7 +28,7 @@ pub struct EntryNotifierService { } impl EntryNotifierService { - pub fn new(entry_notifier: EntryNotifierLock, exit: Arc) -> Self { + pub fn new(entry_notifier: EntryNotifierArc, exit: Arc) -> Self { let (entry_notification_sender, entry_notification_receiver) = unbounded(); let thread_hdl = Builder::new() .name("solEntryNotif".to_string()) @@ -52,14 +52,11 @@ impl EntryNotifierService { fn notify_entry( entry_notification_receiver: &EntryNotifierReceiver, - entry_notifier: EntryNotifierLock, + entry_notifier: EntryNotifierArc, ) -> Result<(), RecvTimeoutError> { let EntryNotification { slot, index, entry } = entry_notification_receiver.recv_timeout(Duration::from_secs(1))?; - entry_notifier - .write() - .unwrap() - .notify_entry(slot, index, &entry); + entry_notifier.notify_entry(slot, index, &entry); Ok(()) } From 5228b709f29d3fc5eb6b9e6cb54a68a3b0ca324f Mon Sep 17 00:00:00 2001 From: vovkman Date: Fri, 27 Oct 2023 13:08:33 -0700 Subject: [PATCH 2/3] remove unused RWLock --- ledger/src/entry_notifier_interface.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ledger/src/entry_notifier_interface.rs b/ledger/src/entry_notifier_interface.rs index 692b55a26767cd..174be9e1b7f1f4 100644 --- a/ledger/src/entry_notifier_interface.rs +++ b/ledger/src/entry_notifier_interface.rs @@ -1,8 +1,4 @@ -use { - solana_entry::entry::EntrySummary, - solana_sdk::clock::Slot, - std::sync::{Arc, RwLock}, -}; +use {solana_entry::entry::EntrySummary, solana_sdk::clock::Slot, std::sync::Arc}; pub trait EntryNotifier { fn notify_entry(&self, slot: Slot, index: usize, entry: &EntrySummary); From 11d76156639f0a886dc972845ba176874d05bb56 Mon Sep 17 00:00:00 2001 From: vovkman Date: Wed, 1 Nov 2023 09:15:41 -0700 Subject: [PATCH 3/3] Remove RWLock --- geyser-plugin-manager/src/geyser_plugin_service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geyser-plugin-manager/src/geyser_plugin_service.rs b/geyser-plugin-manager/src/geyser_plugin_service.rs index fc8c67c10e6db0..b762c210e46dd7 100644 --- a/geyser-plugin-manager/src/geyser_plugin_service.rs +++ b/geyser-plugin-manager/src/geyser_plugin_service.rs @@ -102,7 +102,7 @@ impl GeyserPluginService { let entry_notifier: Option = if entry_notifications_enabled { let entry_notifier = EntryNotifierImpl::new(plugin_manager.clone()); - Some(Arc::new(RwLock::new(entry_notifier))) + Some(Arc::new(entry_notifier)) } else { None };