From df3bf2c00a9affbdf2558baa5fb7faf39445362c Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 21 Aug 2025 08:24:05 +0200 Subject: [PATCH] perf(trie): default ParallelSparseTrie to enabled (accounts only still) (#17956) --- crates/engine/primitives/src/config.rs | 22 +++++++++---------- .../tree/src/tree/payload_processor/mod.rs | 10 ++++----- .../engine/tree/tests/e2e-testsuite/main.rs | 5 +---- crates/node/core/src/args/engine.rs | 15 +++++++++---- docs/cli/help.rs | 13 ++++------- docs/vocs/docs/pages/cli/reth/node.mdx | 4 ++-- 6 files changed, 34 insertions(+), 35 deletions(-) diff --git a/crates/engine/primitives/src/config.rs b/crates/engine/primitives/src/config.rs index 0ddc35453a..03c83e0895 100644 --- a/crates/engine/primitives/src/config.rs +++ b/crates/engine/primitives/src/config.rs @@ -65,8 +65,8 @@ pub struct TreeConfig { always_compare_trie_updates: bool, /// Whether to disable cross-block caching and parallel prewarming. disable_caching_and_prewarming: bool, - /// Whether to enable the parallel sparse trie state root algorithm. - enable_parallel_sparse_trie: bool, + /// Whether to disable the parallel sparse trie state root algorithm. + disable_parallel_sparse_trie: bool, /// Whether to enable state provider metrics. state_provider_metrics: bool, /// Cross-block cache size in bytes. @@ -108,7 +108,7 @@ impl Default for TreeConfig { legacy_state_root: false, always_compare_trie_updates: false, disable_caching_and_prewarming: false, - enable_parallel_sparse_trie: false, + disable_parallel_sparse_trie: false, state_provider_metrics: false, cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE, has_enough_parallelism: has_enough_parallelism(), @@ -133,7 +133,7 @@ impl TreeConfig { legacy_state_root: bool, always_compare_trie_updates: bool, disable_caching_and_prewarming: bool, - enable_parallel_sparse_trie: bool, + disable_parallel_sparse_trie: bool, state_provider_metrics: bool, cross_block_cache_size: u64, has_enough_parallelism: bool, @@ -152,7 +152,7 @@ impl TreeConfig { legacy_state_root, always_compare_trie_updates, disable_caching_and_prewarming, - enable_parallel_sparse_trie, + disable_parallel_sparse_trie, state_provider_metrics, cross_block_cache_size, has_enough_parallelism, @@ -210,9 +210,9 @@ impl TreeConfig { self.state_provider_metrics } - /// Returns whether or not the parallel sparse trie is enabled. - pub const fn enable_parallel_sparse_trie(&self) -> bool { - self.enable_parallel_sparse_trie + /// Returns whether or not the parallel sparse trie is disabled. + pub const fn disable_parallel_sparse_trie(&self) -> bool { + self.disable_parallel_sparse_trie } /// Returns whether or not cross-block caching and parallel prewarming should be used. @@ -340,11 +340,11 @@ impl TreeConfig { } /// Setter for using the parallel sparse trie - pub const fn with_enable_parallel_sparse_trie( + pub const fn with_disable_parallel_sparse_trie( mut self, - enable_parallel_sparse_trie: bool, + disable_parallel_sparse_trie: bool, ) -> Self { - self.enable_parallel_sparse_trie = enable_parallel_sparse_trie; + self.disable_parallel_sparse_trie = disable_parallel_sparse_trie; self } diff --git a/crates/engine/tree/src/tree/payload_processor/mod.rs b/crates/engine/tree/src/tree/payload_processor/mod.rs index 1133078978..15092e0714 100644 --- a/crates/engine/tree/src/tree/payload_processor/mod.rs +++ b/crates/engine/tree/src/tree/payload_processor/mod.rs @@ -79,7 +79,7 @@ where parking_lot::Mutex>>, >, /// Whether to use the parallel sparse trie. - use_parallel_sparse_trie: bool, + disable_parallel_sparse_trie: bool, /// A cleared trie input, kept around to be reused so allocations can be minimized. trie_input: Option, } @@ -107,7 +107,7 @@ where precompile_cache_map, sparse_state_trie: Arc::default(), trie_input: None, - use_parallel_sparse_trie: config.enable_parallel_sparse_trie(), + disable_parallel_sparse_trie: config.disable_parallel_sparse_trie(), } } } @@ -363,10 +363,10 @@ where // there's none to reuse. let cleared_sparse_trie = Arc::clone(&self.sparse_state_trie); let sparse_state_trie = cleared_sparse_trie.lock().take().unwrap_or_else(|| { - let accounts_trie = if self.use_parallel_sparse_trie { - ConfiguredSparseTrie::Parallel(Default::default()) - } else { + let accounts_trie = if self.disable_parallel_sparse_trie { ConfiguredSparseTrie::Serial(Default::default()) + } else { + ConfiguredSparseTrie::Parallel(Default::default()) }; ClearedSparseStateTrie::from_state_trie( SparseStateTrie::new() diff --git a/crates/engine/tree/tests/e2e-testsuite/main.rs b/crates/engine/tree/tests/e2e-testsuite/main.rs index 0b9162ab8c..cc5240f5f8 100644 --- a/crates/engine/tree/tests/e2e-testsuite/main.rs +++ b/crates/engine/tree/tests/e2e-testsuite/main.rs @@ -33,10 +33,7 @@ fn default_engine_tree_setup() -> Setup { )) .with_network(NetworkSetup::single_node()) .with_tree_config( - TreeConfig::default() - .with_legacy_state_root(false) - .with_has_enough_parallelism(true) - .with_enable_parallel_sparse_trie(true), + TreeConfig::default().with_legacy_state_root(false).with_has_enough_parallelism(true), ) } diff --git a/crates/node/core/src/args/engine.rs b/crates/node/core/src/args/engine.rs index 64829c4c06..6d7ec6986b 100644 --- a/crates/node/core/src/args/engine.rs +++ b/crates/node/core/src/args/engine.rs @@ -34,10 +34,16 @@ pub struct EngineArgs { #[arg(long = "engine.disable-caching-and-prewarming")] pub caching_and_prewarming_disabled: bool, - /// Enable the parallel sparse trie in the engine. - #[arg(long = "engine.parallel-sparse-trie", default_value = "false")] + /// CAUTION: This CLI flag has no effect anymore, use --engine.disable-parallel-sparse-trie + /// if you want to disable usage of the `ParallelSparseTrie`. + #[deprecated] + #[arg(long = "engine.parallel-sparse-trie", default_value = "true", hide = true)] pub parallel_sparse_trie_enabled: bool, + /// Disable the parallel sparse trie in the engine. + #[arg(long = "engine.disable-parallel-sparse-trie", default_value = "false")] + pub parallel_sparse_trie_disabled: bool, + /// Enable state provider latency metrics. This allows the engine to collect and report stats /// about how long state provider calls took during execution, but this does introduce slight /// overhead to state provider calls. @@ -101,7 +107,8 @@ impl Default for EngineArgs { state_root_task_compare_updates: false, caching_and_prewarming_enabled: true, caching_and_prewarming_disabled: false, - parallel_sparse_trie_enabled: false, + parallel_sparse_trie_enabled: true, + parallel_sparse_trie_disabled: false, state_provider_metrics: false, cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, accept_execution_requests_hash: false, @@ -123,7 +130,7 @@ impl EngineArgs { .with_memory_block_buffer_target(self.memory_block_buffer_target) .with_legacy_state_root(self.legacy_state_root_task_enabled) .without_caching_and_prewarming(self.caching_and_prewarming_disabled) - .with_enable_parallel_sparse_trie(self.parallel_sparse_trie_enabled) + .with_disable_parallel_sparse_trie(self.parallel_sparse_trie_disabled) .with_state_provider_metrics(self.state_provider_metrics) .with_always_compare_trie_updates(self.state_root_task_compare_updates) .with_cross_block_cache_size(self.cross_block_cache_size * 1024 * 1024) diff --git a/docs/cli/help.rs b/docs/cli/help.rs index e6813a483a..78cb107b5c 100755 --- a/docs/cli/help.rs +++ b/docs/cli/help.rs @@ -116,11 +116,8 @@ fn main() -> io::Result<()> { } // Generate SUMMARY.mdx. - let summary: String = output - .iter() - .map(|(cmd, _)| cmd_summary(cmd, 0)) - .chain(once("\n".to_string())) - .collect(); + let summary: String = + output.iter().map(|(cmd, _)| cmd_summary(cmd, 0)).chain(once("\n".to_string())).collect(); println!("Writing SUMMARY.mdx to \"{}\"", out_dir.to_string_lossy()); write_file(&out_dir.clone().join("SUMMARY.mdx"), &summary)?; @@ -136,10 +133,8 @@ fn main() -> io::Result<()> { // Generate root SUMMARY.mdx. if args.root_summary { - let root_summary: String = output - .iter() - .map(|(cmd, _)| cmd_summary(cmd, args.root_indentation)) - .collect(); + let root_summary: String = + output.iter().map(|(cmd, _)| cmd_summary(cmd, args.root_indentation)).collect(); let path = Path::new(args.root_dir.as_str()); if args.verbose { diff --git a/docs/vocs/docs/pages/cli/reth/node.mdx b/docs/vocs/docs/pages/cli/reth/node.mdx index a4d3ec1200..a8d795f3a9 100644 --- a/docs/vocs/docs/pages/cli/reth/node.mdx +++ b/docs/vocs/docs/pages/cli/reth/node.mdx @@ -794,8 +794,8 @@ Engine: --engine.disable-caching-and-prewarming Disable cross-block caching and parallel prewarming - --engine.parallel-sparse-trie - Enable the parallel sparse trie in the engine + --engine.disable-parallel-sparse-trie + Disable the parallel sparse trie in the engine --engine.state-provider-metrics Enable state provider latency metrics. This allows the engine to collect and report stats about how long state provider calls took during execution, but this does introduce slight overhead to state provider calls