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:
parent
ebe8afb0c3
commit
e840b9759a
|
@ -58,7 +58,7 @@ use {
|
||||||
},
|
},
|
||||||
blockstore_options::{BlockstoreOptions, BlockstoreRecoveryMode, LedgerColumnOptions},
|
blockstore_options::{BlockstoreOptions, BlockstoreRecoveryMode, LedgerColumnOptions},
|
||||||
blockstore_processor::{self, TransactionStatusSender},
|
blockstore_processor::{self, TransactionStatusSender},
|
||||||
entry_notifier_interface::EntryNotifierLock,
|
entry_notifier_interface::EntryNotifierArc,
|
||||||
entry_notifier_service::{EntryNotifierSender, EntryNotifierService},
|
entry_notifier_service::{EntryNotifierSender, EntryNotifierService},
|
||||||
leader_schedule::FixedSchedule,
|
leader_schedule::FixedSchedule,
|
||||||
leader_schedule_cache::LeaderScheduleCache,
|
leader_schedule_cache::LeaderScheduleCache,
|
||||||
|
@ -1690,7 +1690,7 @@ fn load_blockstore(
|
||||||
start_progress: &Arc<RwLock<ValidatorStartProgress>>,
|
start_progress: &Arc<RwLock<ValidatorStartProgress>>,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
transaction_notifier: Option<TransactionNotifierLock>,
|
transaction_notifier: Option<TransactionNotifierLock>,
|
||||||
entry_notifier: Option<EntryNotifierLock>,
|
entry_notifier: Option<EntryNotifierArc>,
|
||||||
poh_timing_point_sender: Option<PohTimingSender>,
|
poh_timing_point_sender: Option<PohTimingSender>,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
(
|
(
|
||||||
|
|
|
@ -12,7 +12,7 @@ use {
|
||||||
crossbeam_channel::Receiver,
|
crossbeam_channel::Receiver,
|
||||||
log::*,
|
log::*,
|
||||||
solana_accounts_db::accounts_update_notifier_interface::AccountsUpdateNotifier,
|
solana_accounts_db::accounts_update_notifier_interface::AccountsUpdateNotifier,
|
||||||
solana_ledger::entry_notifier_interface::EntryNotifierLock,
|
solana_ledger::entry_notifier_interface::EntryNotifierArc,
|
||||||
solana_rpc::{
|
solana_rpc::{
|
||||||
optimistically_confirmed_bank_tracker::SlotNotification,
|
optimistically_confirmed_bank_tracker::SlotNotification,
|
||||||
transaction_notifier_interface::TransactionNotifierLock,
|
transaction_notifier_interface::TransactionNotifierLock,
|
||||||
|
@ -35,7 +35,7 @@ pub struct GeyserPluginService {
|
||||||
plugin_manager: Arc<RwLock<GeyserPluginManager>>,
|
plugin_manager: Arc<RwLock<GeyserPluginManager>>,
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
transaction_notifier: Option<TransactionNotifierLock>,
|
transaction_notifier: Option<TransactionNotifierLock>,
|
||||||
entry_notifier: Option<EntryNotifierLock>,
|
entry_notifier: Option<EntryNotifierArc>,
|
||||||
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
|
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ impl GeyserPluginService {
|
||||||
None
|
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());
|
let entry_notifier = EntryNotifierImpl::new(plugin_manager.clone());
|
||||||
Some(Arc::new(RwLock::new(entry_notifier)))
|
Some(Arc::new(entry_notifier))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -164,7 +164,7 @@ impl GeyserPluginService {
|
||||||
self.transaction_notifier.clone()
|
self.transaction_notifier.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_entry_notifier(&self) -> Option<EntryNotifierLock> {
|
pub fn get_entry_notifier(&self) -> Option<EntryNotifierArc> {
|
||||||
self.entry_notifier.clone()
|
self.entry_notifier.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
use {
|
use {solana_entry::entry::EntrySummary, solana_sdk::clock::Slot, std::sync::Arc};
|
||||||
solana_entry::entry::EntrySummary,
|
|
||||||
solana_sdk::clock::Slot,
|
|
||||||
std::sync::{Arc, RwLock},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait EntryNotifier {
|
pub trait EntryNotifier {
|
||||||
fn notify_entry(&self, slot: Slot, index: usize, entry: &EntrySummary);
|
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>;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use {
|
use {
|
||||||
crate::entry_notifier_interface::EntryNotifierLock,
|
crate::entry_notifier_interface::EntryNotifierArc,
|
||||||
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
|
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
|
||||||
solana_entry::entry::EntrySummary,
|
solana_entry::entry::EntrySummary,
|
||||||
solana_sdk::clock::Slot,
|
solana_sdk::clock::Slot,
|
||||||
|
@ -28,7 +28,7 @@ pub struct EntryNotifierService {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 (entry_notification_sender, entry_notification_receiver) = unbounded();
|
||||||
let thread_hdl = Builder::new()
|
let thread_hdl = Builder::new()
|
||||||
.name("solEntryNotif".to_string())
|
.name("solEntryNotif".to_string())
|
||||||
|
@ -52,14 +52,11 @@ impl EntryNotifierService {
|
||||||
|
|
||||||
fn notify_entry(
|
fn notify_entry(
|
||||||
entry_notification_receiver: &EntryNotifierReceiver,
|
entry_notification_receiver: &EntryNotifierReceiver,
|
||||||
entry_notifier: EntryNotifierLock,
|
entry_notifier: EntryNotifierArc,
|
||||||
) -> Result<(), RecvTimeoutError> {
|
) -> Result<(), RecvTimeoutError> {
|
||||||
let EntryNotification { slot, index, entry } =
|
let EntryNotification { slot, index, entry } =
|
||||||
entry_notification_receiver.recv_timeout(Duration::from_secs(1))?;
|
entry_notification_receiver.recv_timeout(Duration::from_secs(1))?;
|
||||||
entry_notifier
|
entry_notifier.notify_entry(slot, index, &entry);
|
||||||
.write()
|
|
||||||
.unwrap()
|
|
||||||
.notify_entry(slot, index, &entry);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue