Remove RwLock on BlockNotifier (#33981)

This commit is contained in:
Lijun Wang 2023-11-08 10:27:50 -08:00 committed by GitHub
parent 7cdfba9259
commit 69cec7e7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 14 deletions

View File

@ -36,7 +36,7 @@ use {
lazy_static::lazy_static,
rayon::{prelude::*, ThreadPool},
solana_entry::entry::VerifyRecyclers,
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierLock,
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierArc,
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::{
block_error::BlockError,
@ -492,7 +492,7 @@ impl ReplayStage {
cost_update_sender: Sender<CostUpdate>,
voting_sender: Sender<VoteOp>,
drop_bank_sender: Sender<Vec<Arc<Bank>>>,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
block_metadata_notifier: Option<BlockMetadataNotifierArc>,
log_messages_bytes_limit: Option<usize>,
prioritization_fee_cache: Arc<PrioritizationFeeCache>,
dumped_slots_sender: DumpedSlotsSender,
@ -2760,7 +2760,7 @@ impl ReplayStage {
cost_update_sender: &Sender<CostUpdate>,
duplicate_slots_to_repair: &mut DuplicateSlotsToRepair,
ancestor_hashes_replay_update_sender: &AncestorHashesReplayUpdateSender,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
block_metadata_notifier: Option<BlockMetadataNotifierArc>,
replay_result_vec: &[ReplaySlotFromBlockstore],
purge_repair_slot_counter: &mut PurgeRepairSlotCounter,
) -> bool {
@ -2951,7 +2951,6 @@ impl ReplayStage {
}
Self::record_rewards(bank, rewards_recorder_sender);
if let Some(ref block_metadata_notifier) = block_metadata_notifier {
let block_metadata_notifier = block_metadata_notifier.read().unwrap();
let parent_blockhash = bank
.parent()
.map(|bank| bank.last_blockhash())
@ -3016,7 +3015,7 @@ impl ReplayStage {
cost_update_sender: &Sender<CostUpdate>,
duplicate_slots_to_repair: &mut DuplicateSlotsToRepair,
ancestor_hashes_replay_update_sender: &AncestorHashesReplayUpdateSender,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
block_metadata_notifier: Option<BlockMetadataNotifierArc>,
replay_timing: &mut ReplayTiming,
log_messages_bytes_limit: Option<usize>,
replay_slots_concurrently: bool,

View File

@ -25,7 +25,7 @@ use {
bytes::Bytes,
crossbeam_channel::{unbounded, Receiver, Sender},
solana_client::connection_cache::ConnectionCache,
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierLock,
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierArc,
solana_gossip::{
cluster_info::ClusterInfo, duplicate_shred_handler::DuplicateShredHandler,
duplicate_shred_listener::DuplicateShredListener,
@ -128,7 +128,7 @@ impl Tvu {
gossip_confirmed_slots_receiver: GossipDuplicateConfirmedSlotsReceiver,
tvu_config: TvuConfig,
max_slots: &Arc<MaxSlots>,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
block_metadata_notifier: Option<BlockMetadataNotifierArc>,
wait_to_vote_slot: Option<Slot>,
accounts_background_request_sender: AbsRequestSender,
log_messages_bytes_limit: Option<usize>,

View File

@ -22,4 +22,4 @@ pub trait BlockMetadataNotifier {
);
}
pub type BlockMetadataNotifierLock = Arc<RwLock<dyn BlockMetadataNotifier + Sync + Send>>;
pub type BlockMetadataNotifierArc = Arc<dyn BlockMetadataNotifier + Sync + Send>;

View File

@ -2,7 +2,7 @@ use {
crate::{
accounts_update_notifier::AccountsUpdateNotifierImpl,
block_metadata_notifier::BlockMetadataNotifierImpl,
block_metadata_notifier_interface::BlockMetadataNotifierLock,
block_metadata_notifier_interface::BlockMetadataNotifierArc,
entry_notifier::EntryNotifierImpl,
geyser_plugin_manager::{GeyserPluginManager, GeyserPluginManagerRequest},
slot_status_notifier::SlotStatusNotifierImpl,
@ -36,7 +36,7 @@ pub struct GeyserPluginService {
accounts_update_notifier: Option<AccountsUpdateNotifier>,
transaction_notifier: Option<TransactionNotifierArc>,
entry_notifier: Option<EntryNotifierArc>,
block_metadata_notifier: Option<BlockMetadataNotifierLock>,
block_metadata_notifier: Option<BlockMetadataNotifierArc>,
}
impl GeyserPluginService {
@ -109,7 +109,7 @@ impl GeyserPluginService {
let (slot_status_observer, block_metadata_notifier): (
Option<SlotStatusObserver>,
Option<BlockMetadataNotifierLock>,
Option<BlockMetadataNotifierArc>,
) = if account_data_notifications_enabled
|| transaction_notifications_enabled
|| entry_notifications_enabled
@ -121,9 +121,9 @@ impl GeyserPluginService {
confirmed_bank_receiver,
slot_status_notifier,
)),
Some(Arc::new(RwLock::new(BlockMetadataNotifierImpl::new(
Some(Arc::new(BlockMetadataNotifierImpl::new(
plugin_manager.clone(),
)))),
))),
)
} else {
(None, None)
@ -168,7 +168,7 @@ impl GeyserPluginService {
self.entry_notifier.clone()
}
pub fn get_block_metadata_notifier(&self) -> Option<BlockMetadataNotifierLock> {
pub fn get_block_metadata_notifier(&self) -> Option<BlockMetadataNotifierArc> {
self.block_metadata_notifier.clone()
}