From 7ff78ca082b2edf653188b10796ca817aa364cd9 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 12 Feb 2026 12:07:52 -0500 Subject: [PATCH] perf(engine): use transaction count threshold for prewarm skip (#22094) Co-authored-by: yk Co-authored-by: Amp Co-authored-by: Ubuntu Co-authored-by: YK --- crates/engine/tree/src/tree/payload_processor/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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));