diff --git a/crates/engine/tree/src/tree/payload_processor/mod.rs b/crates/engine/tree/src/tree/payload_processor/mod.rs index b1ea7c7006..7c2b6af61f 100644 --- a/crates/engine/tree/src/tree/payload_processor/mod.rs +++ b/crates/engine/tree/src/tree/payload_processor/mod.rs @@ -94,6 +94,9 @@ pub const SPARSE_TRIE_MAX_NODES_SHRINK_CAPACITY: usize = 1_000_000; /// 144MB. pub const SPARSE_TRIE_MAX_VALUES_SHRINK_CAPACITY: usize = 1_000_000; +/// Blocks with fewer transactions than this skip prewarming, since the fixed overhead of spawning +/// prewarm workers exceeds the execution time saved. +pub const SMALL_BLOCK_TX_THRESHOLD: usize = 5; /// Type alias for [`PayloadHandle`] returned by payload processor spawn methods. type IteratorPayloadHandle = PayloadHandle< WithTxEnv, >::Recovered>, @@ -469,7 +472,8 @@ where where P: BlockReader + StateProviderFactory + StateReader + Clone + 'static, { - let skip_prewarm = self.disable_transaction_prewarming; + let skip_prewarm = + self.disable_transaction_prewarming || env.transaction_count < SMALL_BLOCK_TX_THRESHOLD; let saved_cache = self.disable_state_cache.not().then(|| self.cache_for(env.parent_hash));