diff --git a/crates/engine/primitives/src/config.rs b/crates/engine/primitives/src/config.rs index 0b9b7d9f82..d846268b91 100644 --- a/crates/engine/primitives/src/config.rs +++ b/crates/engine/primitives/src/config.rs @@ -30,7 +30,7 @@ fn default_account_worker_count() -> usize { } /// The size of proof targets chunk to spawn in one multiproof calculation. -pub const DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE: usize = 10; +pub const DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE: usize = 60; /// Default number of reserved CPU cores for non-reth processes. /// diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 7da199dd63..88c82b55db 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -27,6 +27,10 @@ use reth_trie_parallel::{ use std::{collections::BTreeMap, ops::DerefMut, sync::Arc, time::Instant}; use tracing::{debug, error, instrument, trace}; +/// The default max targets, for limiting the number of account and storage proof targets to be +/// fetched by a single worker. +const DEFAULT_MAX_TARGETS_FOR_CHUNKING: usize = 300; + /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state. #[derive(Default, Debug)] @@ -704,6 +708,10 @@ pub(super) struct MultiProofTask { multiproof_manager: MultiproofManager, /// multi proof task metrics metrics: MultiProofTaskMetrics, + /// If this number is exceeded and chunking is enabled, then this will override whether or not + /// there are any active workers and force chunking across workers. This is to prevent tasks + /// which are very long from hitting a single worker. + max_targets_for_chunking: usize, } impl MultiProofTask { @@ -732,6 +740,7 @@ impl MultiProofTask { proof_result_tx, ), metrics, + max_targets_for_chunking: DEFAULT_MAX_TARGETS_FOR_CHUNKING, } } @@ -921,10 +930,14 @@ impl MultiProofTask { let mut spawned_proof_targets = MultiProofTargets::default(); + // Chunk regardless if there are many proof targets + let many_proof_targets = + not_fetched_state_update.chunking_length() > self.max_targets_for_chunking; + // Only chunk if multiple account or storage workers are available to take advantage of // parallelism. - let should_chunk = self.multiproof_manager.proof_worker_handle.available_account_workers() > - 1 || + let should_chunk = many_proof_targets || + self.multiproof_manager.proof_worker_handle.available_account_workers() > 1 || self.multiproof_manager.proof_worker_handle.available_storage_workers() > 1; let mut dispatch = |hashed_state_update| { diff --git a/docs/vocs/docs/pages/cli/reth/node.mdx b/docs/vocs/docs/pages/cli/reth/node.mdx index 51e504fece..bed2a926da 100644 --- a/docs/vocs/docs/pages/cli/reth/node.mdx +++ b/docs/vocs/docs/pages/cli/reth/node.mdx @@ -909,7 +909,7 @@ Engine: --engine.multiproof-chunk-size Multiproof task chunk size for proof targets - [default: 10] + [default: 60] --engine.reserved-cpu-cores Configure the number of reserved CPU cores for non-reth processes