Remove chain-joining thread-selection (#34554)
This commit is contained in:
parent
88f8d11da2
commit
ac04a758e1
|
@ -20,7 +20,6 @@ use {
|
|||
pubkey::Pubkey, saturating_add_assign, slot_history::Slot,
|
||||
transaction::SanitizedTransaction,
|
||||
},
|
||||
std::collections::HashMap,
|
||||
};
|
||||
|
||||
pub(crate) struct PrioGraphScheduler {
|
||||
|
@ -70,7 +69,6 @@ impl PrioGraphScheduler {
|
|||
) -> Result<SchedulingSummary, SchedulerError> {
|
||||
let num_threads = self.consume_work_senders.len();
|
||||
let mut batches = Batches::new(num_threads);
|
||||
let mut chain_id_to_thread_index = HashMap::new();
|
||||
// Some transactions may be unschedulable due to multi-thread conflicts.
|
||||
// These transactions cannot be scheduled until some conflicting work is completed.
|
||||
// However, the scheduler should not allow other transactions that conflict with
|
||||
|
@ -170,10 +168,6 @@ impl PrioGraphScheduler {
|
|||
continue;
|
||||
}
|
||||
|
||||
let maybe_chain_thread = chain_id_to_thread_index
|
||||
.get(&prio_graph.chain_id(&id))
|
||||
.copied();
|
||||
|
||||
// Schedule the transaction if it can be.
|
||||
let transaction_locks = transaction.get_account_locks_unchecked();
|
||||
let Some(thread_id) = self.account_locks.try_lock_accounts(
|
||||
|
@ -183,7 +177,6 @@ impl PrioGraphScheduler {
|
|||
|thread_set| {
|
||||
Self::select_thread(
|
||||
thread_set,
|
||||
maybe_chain_thread,
|
||||
&batches.transactions,
|
||||
self.in_flight_tracker.num_in_flight_per_thread(),
|
||||
)
|
||||
|
@ -197,9 +190,6 @@ impl PrioGraphScheduler {
|
|||
|
||||
saturating_add_assign!(num_scheduled, 1);
|
||||
|
||||
// Track the chain-id to thread-index mapping.
|
||||
chain_id_to_thread_index.insert(prio_graph.chain_id(&id), thread_id);
|
||||
|
||||
let sanitized_transaction_ttl = transaction_state.transition_to_pending();
|
||||
let cu_limit = transaction_state
|
||||
.transaction_priority_details()
|
||||
|
@ -403,16 +393,9 @@ impl PrioGraphScheduler {
|
|||
/// Panics if the `thread_set` is empty.
|
||||
fn select_thread(
|
||||
thread_set: ThreadSet,
|
||||
chain_thread: Option<ThreadId>,
|
||||
batches_per_thread: &[Vec<SanitizedTransaction>],
|
||||
in_flight_per_thread: &[usize],
|
||||
) -> ThreadId {
|
||||
if let Some(chain_thread) = chain_thread {
|
||||
if thread_set.contains(chain_thread) {
|
||||
return chain_thread;
|
||||
}
|
||||
}
|
||||
|
||||
thread_set
|
||||
.contained_threads_iter()
|
||||
.map(|thread_id| {
|
||||
|
@ -710,42 +693,6 @@ mod tests {
|
|||
assert_eq!(collect_work(&work_receivers[1]).1, [txids!([2, 0])]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_schedule_look_ahead() {
|
||||
let (mut scheduler, work_receivers, _finished_work_sender) = create_test_frame(2);
|
||||
|
||||
let accounts = (0..6).map(|_| Keypair::new()).collect_vec();
|
||||
let mut container = create_container([
|
||||
(&accounts[0], &[accounts[1].pubkey()], 1, 4),
|
||||
(&accounts[1], &[accounts[2].pubkey()], 1, 3),
|
||||
(&accounts[3], &[accounts[4].pubkey()], 1, 2),
|
||||
(&accounts[4], &[accounts[5].pubkey()], 1, 1),
|
||||
(&accounts[2], &[accounts[5].pubkey()], 1, 0),
|
||||
]);
|
||||
|
||||
// The look-ahead window allows the prio-graph to have a limited view of
|
||||
// upcoming transactions, so that un-schedulable transactions are less
|
||||
// likely to occur. In this case, we have 5 transactions that have a
|
||||
// prio-graph that can be visualized as:
|
||||
// [0] --> [1] \
|
||||
// -> [4]
|
||||
// /
|
||||
// [2] --> [3]
|
||||
// Even though [0] and [2] could be scheduled to different threads, the
|
||||
// fact they eventually join means that the scheduler will schedule them
|
||||
// onto the same thread to avoid causing [4], which conflicts with both
|
||||
// chains, to be un-schedulable.
|
||||
let scheduling_summary = scheduler
|
||||
.schedule(&mut container, test_pre_graph_filter, test_pre_lock_filter)
|
||||
.unwrap();
|
||||
assert_eq!(scheduling_summary.num_scheduled, 5);
|
||||
assert_eq!(scheduling_summary.num_unschedulable, 0);
|
||||
assert_eq!(
|
||||
collect_work(&work_receivers[0]).1,
|
||||
[txids!([0, 2]), txids!([1, 3]), txids!([4])]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_schedule_priority_guard() {
|
||||
let (mut scheduler, work_receivers, finished_work_sender) = create_test_frame(2);
|
||||
|
|
Loading…
Reference in New Issue