From 97588a07a4ef4a435564a72cccb33b198bbed9ed Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 4 Feb 2026 23:07:14 +0100 Subject: [PATCH] perf(engine): use par_bridge_buffered instead of par_bridge for storage trie updates (#21827) Co-authored-by: Amp --- .../engine/tree/src/tree/payload_processor/sparse_trie.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/engine/tree/src/tree/payload_processor/sparse_trie.rs b/crates/engine/tree/src/tree/payload_processor/sparse_trie.rs index c9e469a279..a3bd37a356 100644 --- a/crates/engine/tree/src/tree/payload_processor/sparse_trie.rs +++ b/crates/engine/tree/src/tree/payload_processor/sparse_trie.rs @@ -10,7 +10,7 @@ use crate::tree::{ use alloy_primitives::B256; use alloy_rlp::{Decodable, Encodable}; use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender}; -use rayon::iter::{IntoParallelRefMutIterator, ParallelBridge, ParallelIterator}; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use reth_primitives_traits::{Account, ParallelBridgeBuffered}; use reth_revm::state::EvmState; use reth_trie::{ @@ -533,17 +533,18 @@ where fn process_leaf_updates(&mut self) -> SparseTrieResult<()> { self.pending_updates = 0; - // Start with processing all storage updates in parallel. + // Process all storage updates in parallel, skipping tries with no pending updates. let storage_results = self .storage_updates .iter_mut() + .filter(|(_, updates)| !updates.is_empty()) .map(|(address, updates)| { let trie = self.trie.take_or_create_storage_trie(address); let fetched = self.fetched_storage_targets.remove(address).unwrap_or_default(); (address, updates, fetched, trie) }) - .par_bridge() + .par_bridge_buffered() .map(|(address, updates, mut fetched, mut trie)| { let mut targets = Vec::new();