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

Poh using mpsc ringbuf #3361

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
7 changes: 4 additions & 3 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ mod tests {
use {
super::*,
crate::banking_trace::{BankingPacketBatch, BankingTracer},
crossbeam_channel::{unbounded, Receiver},
crossbeam_channel::unbounded,
itertools::Itertools,
solana_entry::entry::{self, Entry, EntrySlice},
solana_gossip::cluster_info::Node,
Expand All @@ -835,6 +835,7 @@ mod tests {
},
solana_perf::packet::{to_packet_batches, PacketBatch},
solana_poh::{
mpsc_ringbuffer::ArrayQueue,
poh_recorder::{
create_test_recorder, PohRecorderError, Record, RecordTransactionsSummary,
},
Expand Down Expand Up @@ -1339,7 +1340,7 @@ mod tests {
}

pub(crate) fn simulate_poh(
record_receiver: Receiver<Record>,
record_receiver: Arc<ArrayQueue<Record>>,
poh_recorder: &Arc<RwLock<PohRecorder>>,
) -> JoinHandle<()> {
let poh_recorder = poh_recorder.clone();
Expand All @@ -1349,7 +1350,7 @@ mod tests {
.spawn(move || loop {
PohService::read_record_receiver_and_process(
&poh_recorder,
&record_receiver,
record_receiver.clone(),
Duration::from_millis(10),
);
if is_exited.load(Ordering::Relaxed) {
Expand Down
15 changes: 9 additions & 6 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,10 @@ mod tests {
leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::Packet,
solana_poh::poh_recorder::{PohRecorder, Record, WorkingBankEntry},
solana_poh::{
mpsc_ringbuffer::ArrayQueue,
poh_recorder::{PohRecorder, Record, WorkingBankEntry},
},
solana_rpc::transaction_status_service::TransactionStatusService,
solana_runtime::{bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache},
solana_sdk::{
Expand Down Expand Up @@ -1254,25 +1257,25 @@ mod tests {
let poh_recorder = Arc::new(RwLock::new(poh_recorder));

fn poh_tick_before_returning_record_response(
record_receiver: Receiver<Record>,
record_receiver: Arc<ArrayQueue<Record>>,
poh_recorder: Arc<RwLock<PohRecorder>>,
) -> JoinHandle<()> {
let is_exited = poh_recorder.read().unwrap().is_exited.clone();
let tick_producer = Builder::new()
.name("solana-simulate_poh".to_string())
.spawn(move || loop {
let timeout = Duration::from_millis(10);
let record = record_receiver.recv_timeout(timeout);
if let Ok(record) = record {
let record = record_receiver.pop_with_timeout(timeout);
if let Some(record) = record {
let record_response = poh_recorder.write().unwrap().record(
record.slot,
record.mixin,
record.transactions,
);
poh_recorder.write().unwrap().tick();
if record.sender.send(record_response).is_err() {
if record_response.is_err() {
panic!("Error returning mixin hash");
}
poh_recorder.write().unwrap().tick();
}
if is_exited.load(Ordering::Relaxed) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,10 @@ mod tests {
get_tmp_ledger_path_auto_delete, leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::{to_packet_batches, PacketBatch, NUM_PACKETS},
solana_poh::poh_recorder::{PohRecorder, Record, WorkingBankEntry},
solana_poh::{
mpsc_ringbuffer::ArrayQueue,
poh_recorder::{PohRecorder, Record, WorkingBankEntry},
},
solana_runtime::bank::Bank,
solana_sdk::{
compute_budget::ComputeBudgetInstruction, fee_calculator::FeeRateGovernor, hash::Hash,
Expand All @@ -754,7 +757,7 @@ mod tests {
mint_keypair: Keypair,
_ledger_path: TempDir,
_entry_receiver: Receiver<WorkingBankEntry>,
_record_receiver: Receiver<Record>,
_record_receiver: Arc<ArrayQueue<Record>>,
poh_recorder: Arc<RwLock<PohRecorder>>,
banking_packet_sender: Sender<Arc<(Vec<PacketBatch>, Option<SigverifyTracerPacketStats>)>>,

Expand Down Expand Up @@ -799,7 +802,7 @@ mod tests {
mint_keypair,
_ledger_path: ledger_path,
_entry_receiver: entry_receiver,
_record_receiver: record_receiver,
_record_receiver: record_receiver.clone(),
poh_recorder,
banking_packet_sender,
consume_work_receivers,
Expand Down
2 changes: 2 additions & 0 deletions poh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pub mod leader_bank_notifier;
pub mod poh_recorder;
pub mod poh_service;

pub mod mpsc_ringbuffer;

#[macro_use]
extern crate solana_metrics;

Expand Down
Loading
Loading