|
|
@@ -404,11 +404,14 @@ impl BankingStage {
|
|
|
committer,
|
|
|
log_messages_bytes_limit,
|
|
|
};
|
|
|
- let non_vote_thread_hdls = Self::new_central_scheduler(
|
|
|
+ // + 1 for the scheduler thread
|
|
|
+ let mut non_vote_thread_hdls = Vec::with_capacity(num_workers.get() + 1);
|
|
|
+ Self::new_central_scheduler(
|
|
|
+ &mut non_vote_thread_hdls,
|
|
|
transaction_struct,
|
|
|
use_greedy_scheduler,
|
|
|
num_workers,
|
|
|
- non_vote_context.clone(),
|
|
|
+ &non_vote_context,
|
|
|
);
|
|
|
|
|
|
Self {
|
|
|
@@ -418,12 +421,48 @@ impl BankingStage {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ pub fn spawn_non_vote_threads(
|
|
|
+ &mut self,
|
|
|
+ transaction_struct: TransactionStructure,
|
|
|
+ block_production_method: BlockProductionMethod,
|
|
|
+ num_workers: NonZeroUsize,
|
|
|
+ ) -> thread::Result<()> {
|
|
|
+ if let Some(context) = self.non_vote_context.as_ref() {
|
|
|
+ info!("Shutting down banking stage non-vote threads");
|
|
|
+ context.non_vote_exit_signal.store(true, Ordering::Relaxed);
|
|
|
+ for bank_thread_hdl in self.non_vote_thread_hdls.drain(..) {
|
|
|
+ bank_thread_hdl.join()?;
|
|
|
+ }
|
|
|
+
|
|
|
+ info!(
|
|
|
+ "Spawning new banking stage non-vote threads with block-production-method: {:?} \
|
|
|
+ transaction-structure: {:?} num-workers: {}",
|
|
|
+ block_production_method, transaction_struct, num_workers
|
|
|
+ );
|
|
|
+ context.non_vote_exit_signal.store(false, Ordering::Relaxed);
|
|
|
+ Self::new_central_scheduler(
|
|
|
+ &mut self.non_vote_thread_hdls,
|
|
|
+ transaction_struct,
|
|
|
+ matches!(
|
|
|
+ block_production_method,
|
|
|
+ BlockProductionMethod::CentralSchedulerGreedy
|
|
|
+ ),
|
|
|
+ num_workers,
|
|
|
+ context,
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
+
|
|
|
fn new_central_scheduler(
|
|
|
+ non_vote_thread_hdls: &mut Vec<JoinHandle<()>>,
|
|
|
transaction_struct: TransactionStructure,
|
|
|
use_greedy_scheduler: bool,
|
|
|
num_workers: NonZeroUsize,
|
|
|
- context: BankingStageNonVoteContext,
|
|
|
- ) -> Vec<JoinHandle<()>> {
|
|
|
+ context: &BankingStageNonVoteContext,
|
|
|
+ ) {
|
|
|
+ assert!(non_vote_thread_hdls.is_empty());
|
|
|
match transaction_struct {
|
|
|
TransactionStructure::Sdk => {
|
|
|
let receive_and_buffer = SanitizedTransactionReceiveAndBuffer::new(
|
|
|
@@ -431,6 +470,7 @@ impl BankingStage {
|
|
|
context.bank_forks.clone(),
|
|
|
);
|
|
|
Self::spawn_scheduler_and_workers(
|
|
|
+ non_vote_thread_hdls,
|
|
|
receive_and_buffer,
|
|
|
use_greedy_scheduler,
|
|
|
num_workers,
|
|
|
@@ -443,6 +483,7 @@ impl BankingStage {
|
|
|
bank_forks: context.bank_forks.clone(),
|
|
|
};
|
|
|
Self::spawn_scheduler_and_workers(
|
|
|
+ non_vote_thread_hdls,
|
|
|
receive_and_buffer,
|
|
|
use_greedy_scheduler,
|
|
|
num_workers,
|
|
|
@@ -453,19 +494,17 @@ impl BankingStage {
|
|
|
}
|
|
|
|
|
|
fn spawn_scheduler_and_workers<R: ReceiveAndBuffer + Send + Sync + 'static>(
|
|
|
+ non_vote_thread_hdls: &mut Vec<JoinHandle<()>>,
|
|
|
receive_and_buffer: R,
|
|
|
use_greedy_scheduler: bool,
|
|
|
num_workers: NonZeroUsize,
|
|
|
- context: BankingStageNonVoteContext,
|
|
|
- ) -> Vec<JoinHandle<()>> {
|
|
|
+ context: &BankingStageNonVoteContext,
|
|
|
+ ) {
|
|
|
assert!(num_workers <= BankingStage::max_num_workers());
|
|
|
let num_workers = num_workers.get();
|
|
|
|
|
|
let exit = context.non_vote_exit_signal.clone();
|
|
|
|
|
|
- // + 1 for scheduler thread
|
|
|
- let mut thread_hdls = Vec::with_capacity(num_workers + 1);
|
|
|
-
|
|
|
// Create channels for communication between scheduler and workers
|
|
|
let (work_senders, work_receivers): (Vec<Sender<_>>, Vec<Receiver<_>>) =
|
|
|
(0..num_workers).map(|_| unbounded()).unzip();
|
|
|
@@ -491,7 +530,7 @@ impl BankingStage {
|
|
|
);
|
|
|
|
|
|
worker_metrics.push(consume_worker.metrics_handle());
|
|
|
- thread_hdls.push(
|
|
|
+ non_vote_thread_hdls.push(
|
|
|
Builder::new()
|
|
|
.name(format!("solCoWorker{id:02}"))
|
|
|
.spawn(move || {
|
|
|
@@ -507,7 +546,8 @@ impl BankingStage {
|
|
|
macro_rules! spawn_scheduler {
|
|
|
($scheduler:ident) => {
|
|
|
let exit = exit.clone();
|
|
|
- thread_hdls.push(
|
|
|
+ let bank_forks = context.bank_forks.clone();
|
|
|
+ non_vote_thread_hdls.push(
|
|
|
Builder::new()
|
|
|
.name("solBnkTxSched".to_string())
|
|
|
.spawn(move || {
|
|
|
@@ -515,7 +555,7 @@ impl BankingStage {
|
|
|
exit,
|
|
|
decision_maker,
|
|
|
receive_and_buffer,
|
|
|
- context.bank_forks.clone(),
|
|
|
+ bank_forks,
|
|
|
$scheduler,
|
|
|
worker_metrics,
|
|
|
);
|
|
|
@@ -549,8 +589,6 @@ impl BankingStage {
|
|
|
);
|
|
|
spawn_scheduler!(scheduler);
|
|
|
}
|
|
|
-
|
|
|
- thread_hdls
|
|
|
}
|
|
|
|
|
|
fn spawn_vote_worker(
|