Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RWLock from EntryNotifier because it causes perf degradation #33797

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<
(
Expand Down
10 changes: 5 additions & 5 deletions geyser-plugin-manager/src/geyser_plugin_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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>,
}

Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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()
}

Expand Down
8 changes: 2 additions & 6 deletions ledger/src/entry_notifier_interface.rs
Original file line number Diff line number Diff line change
@@ -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>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the unused RwLock to make sure clippy is happy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

pub type EntryNotifierArc = Arc<dyn EntryNotifier + Sync + Send>;
11 changes: 4 additions & 7 deletions ledger/src/entry_notifier_service.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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())
Expand All @@ -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(())
}

Expand Down