Skip to content
Closed
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
9 changes: 6 additions & 3 deletions crates/engine/tree/src/tree/payload_processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ where
&self,
transactions: I,
) -> (
mpsc::Receiver<WithTxEnv<TxEnvFor<Evm>, I::Recovered>>,
mpsc::Receiver<(usize, WithTxEnv<TxEnvFor<Evm>, I::Recovered>)>,
mpsc::Receiver<Result<WithTxEnv<TxEnvFor<Evm>, I::Recovered>, I::Error>>,
usize,
) {
Expand All @@ -389,7 +389,7 @@ where
});
// Only send Ok(_) variants to prewarming task.
if let Ok(tx) = &tx {
let _ = prewarm_tx.send(tx.clone());
let _ = prewarm_tx.send((idx, tx.clone()));
}
let _ = ooo_tx.send((idx, tx));
});
Expand Down Expand Up @@ -425,7 +425,10 @@ where
fn spawn_caching_with<P>(
&self,
env: ExecutionEnv<Evm>,
mut transactions: mpsc::Receiver<impl ExecutableTxFor<Evm> + Clone + Send + 'static>,
mut transactions: mpsc::Receiver<(
usize,
impl ExecutableTxFor<Evm> + Clone + Send + 'static,
)>,
transaction_count_hint: usize,
provider_builder: StateProviderBuilder<N, P>,
to_multi_proof: Option<CrossbeamSender<MultiProofMessage>>,
Expand Down
12 changes: 6 additions & 6 deletions crates/engine/tree/src/tree/payload_processor/prewarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use tracing::{debug, debug_span, instrument, trace, warn, Span};
/// Determines the prewarming mode: transaction-based or BAL-based.
pub(super) enum PrewarmMode<Tx> {
/// Prewarm by executing transactions from a stream.
Transactions(Receiver<Tx>),
Transactions(Receiver<(usize, Tx)>),
/// Prewarm by prefetching slots from a Block Access List.
BlockAccessList(Arc<BlockAccessList>),
}
Expand Down Expand Up @@ -152,7 +152,7 @@ where
/// subsequent transactions in the block.
fn spawn_all<Tx>(
&self,
pending: mpsc::Receiver<Tx>,
pending: mpsc::Receiver<(usize, Tx)>,
actions_tx: Sender<PrewarmTaskEvent<N::Receipt>>,
) where
Tx: ExecutableTxFor<Evm> + Clone + Send + 'static,
Expand Down Expand Up @@ -181,8 +181,8 @@ where
let handles = ctx.clone().spawn_workers(workers_needed, &executor, actions_tx.clone(), done_tx.clone());

// Distribute transactions to workers
let mut tx_index = 0usize;
while let Ok(tx) = pending.recv() {
let mut total_tx_executed = 0usize;
while let Ok((tx_index, tx)) = pending.recv() {
Comment thread
DaniPopes marked this conversation as resolved.
// Stop distributing if termination was requested
if ctx.terminate_execution.load(Ordering::Relaxed) {
trace!(
Expand Down Expand Up @@ -218,7 +218,7 @@ where
let _ = handles[worker_idx].send(indexed_tx);
}

tx_index += 1;
total_tx_executed += 1;
}

// drop handle and wait for all tasks to finish and drop theirs
Expand All @@ -227,7 +227,7 @@ where
while done_rx.recv().is_ok() {}

let _ = actions_tx
.send(PrewarmTaskEvent::FinishedTxExecution { executed_transactions: tx_index });
.send(PrewarmTaskEvent::FinishedTxExecution { executed_transactions: total_tx_executed });
});
}

Expand Down
Loading