Skip to content

Commit

Permalink
fix: just do every tx
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Oct 25, 2024
1 parent 68107ef commit 0857c56
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,16 +2196,18 @@ where
info!(target: "engine::tree", "Starting to spawn tx parallel threads");

// We reserve 2 cores for the rest of the system
const RESERVED: usize = 2;
// const RESERVED: usize = 2;

let threads = std::thread::available_parallelism()
.map_or(25, |cpus| max(cpus.get().saturating_sub(RESERVED), RESERVED));
// let threads = std::thread::available_parallelism()
// .map_or(25, |cpus| max(cpus.get().saturating_sub(RESERVED), RESERVED));

let mut sections = vec![vec![]; threads];
for (curr_section, tx) in block.body.transactions().enumerate() {
let idx = curr_section % sections.len();
sections[idx].push(tx.clone());
}
// let mut sections = vec![vec![]; threads];
// for (curr_section, tx) in block.body.transactions().enumerate() {
// let idx = curr_section % sections.len();
// sections[idx].push(tx.clone());
// }

let sections = block.body.transactions().cloned();

// Execute all transactions in parallel and discard the result
for txs in sections {
Expand All @@ -2219,7 +2221,8 @@ where

// modify the block to contain only
let mut modified_block = block.clone();
modified_block.body.transactions = txs;
// modified_block.body.transactions = txs;
modified_block.body.transactions = vec![txs];

let handle = std::thread::spawn(move || {
let cached_state_provider = CachedStateProvider::new(
Expand Down

0 comments on commit 0857c56

Please sign in to comment.