Remove RWLock from EntryNotifier because it causes perf degradation (#33797)

* Remove RWLock from EntryNotifier because it causes perf degradation when entry notifications are enabled on geyser

* remove unused RWLock

* Remove RWLock
This commit is contained in:
Liam Vovk 2023-11-06 00:55:36 -08:00 committed by GitHub
parent ebe8afb0c3
commit e840b9759a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 20 deletions

View File

@ -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,
@ -1690,7 +1690,7 @@ fn load_blockstore(
start_progress: &Arc<RwLock<ValidatorStartProgress>>,
accounts_update_notifier: Option<AccountsUpdateNotifier>,
transaction_notifier: Option<TransactionNotifierLock>,
entry_notifier: Option<EntryNotifierLock>,
entry_notifier: Option<EntryNotifierArc>,
poh_timing_point_sender: Option<PohTimingSender>,
) -> Result<
(

View File

@ -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<RwLock<GeyserPluginManager>>,
accounts_update_notifier: Option<AccountsUpdateNotifier>,
transaction_notifier: Option<TransactionNotifierLock>,
entry_notifier: Option<EntryNotifierLock>,
entry_notifier: Option<EntryNotifierArc>,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
}
@ -100,9 +100,9 @@ impl GeyserPluginService {
None
};
let entry_notifier: Option<EntryNotifierLock> = if entry_notifications_enabled {
let entry_notifier: Option<EntryNotifierArc> = 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
};
@ -164,7 +164,7 @@ impl GeyserPluginService {
self.transaction_notifier.clone()
}
pub fn get_entry_notifier(&self) -> Option<EntryNotifierLock> {
pub fn get_entry_notifier(&self) -> Option<EntryNotifierArc> {
self.entry_notifier.clone()
}

View File

@ -1,11 +1,7 @@
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);
}
pub type EntryNotifierLock = Arc<RwLock<dyn EntryNotifier + Sync + Send>>;
pub type EntryNotifierArc = Arc<dyn EntryNotifier + Sync + Send>;

View File

@ -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<AtomicBool>) -> Self {
pub fn new(entry_notifier: EntryNotifierArc, exit: Arc<AtomicBool>) -> 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(())
}