perf(trie): default ParallelSparseTrie to enabled (accounts only still) (#17956)

This commit is contained in:
Brian Picciano
2025-08-21 08:24:05 +02:00
committed by GitHub
parent 4fe6ae411a
commit df3bf2c00a
6 changed files with 34 additions and 35 deletions

View File

@@ -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
}

View File

@@ -79,7 +79,7 @@ where
parking_lot::Mutex<Option<ClearedSparseStateTrie<ConfiguredSparseTrie, SerialSparseTrie>>>,
>,
/// 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<TrieInput>,
}
@@ -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()

View File

@@ -33,10 +33,7 @@ fn default_engine_tree_setup() -> Setup<EthEngineTypes> {
))
.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),
)
}

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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