From 89cc72b83579f86754aa6dc2050be4dfd7242439 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 08:32:58 +0000 Subject: [PATCH 1/8] refactor: remove max proof task concurrency --- crates/engine/primitives/src/config.rs | 24 ------------------- .../tree/src/tree/payload_processor/mod.rs | 5 ---- .../src/tree/payload_processor/multiproof.rs | 24 +++++++++---------- crates/node/core/src/args/engine.rs | 10 ++------ crates/node/core/src/node_config.rs | 3 +-- docs/cli/help.rs | 5 ---- docs/vocs/docs/pages/cli/reth/node.mdx | 7 +----- 7 files changed, 16 insertions(+), 62 deletions(-) diff --git a/crates/engine/primitives/src/config.rs b/crates/engine/primitives/src/config.rs index 6f759036eb2..0b9b7d9f821 100644 --- a/crates/engine/primitives/src/config.rs +++ b/crates/engine/primitives/src/config.rs @@ -6,9 +6,6 @@ pub const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2; /// How close to the canonical head we persist blocks. pub const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 0; -/// Default maximum concurrency for on-demand proof tasks (blinded nodes) -pub const DEFAULT_MAX_PROOF_TASK_CONCURRENCY: u64 = 256; - /// Minimum number of workers we allow configuring explicitly. pub const MIN_WORKER_COUNT: usize = 32; @@ -102,8 +99,6 @@ pub struct TreeConfig { cross_block_cache_size: u64, /// Whether the host has enough parallelism to run state root task. has_enough_parallelism: bool, - /// Maximum number of concurrent proof tasks - max_proof_task_concurrency: u64, /// Whether multiproof task should chunk proof targets. multiproof_chunking_enabled: bool, /// Multiproof task chunk size for proof targets. @@ -153,7 +148,6 @@ impl Default for TreeConfig { state_provider_metrics: false, cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE, has_enough_parallelism: has_enough_parallelism(), - max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY, multiproof_chunking_enabled: true, multiproof_chunk_size: DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE, reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES, @@ -184,7 +178,6 @@ impl TreeConfig { state_provider_metrics: bool, cross_block_cache_size: u64, has_enough_parallelism: bool, - max_proof_task_concurrency: u64, multiproof_chunking_enabled: bool, multiproof_chunk_size: usize, reserved_cpu_cores: usize, @@ -196,7 +189,6 @@ impl TreeConfig { storage_worker_count: usize, account_worker_count: usize, ) -> Self { - assert!(max_proof_task_concurrency > 0, "max_proof_task_concurrency must be at least 1"); Self { persistence_threshold, memory_block_buffer_target, @@ -210,7 +202,6 @@ impl TreeConfig { state_provider_metrics, cross_block_cache_size, has_enough_parallelism, - max_proof_task_concurrency, multiproof_chunking_enabled, multiproof_chunk_size, reserved_cpu_cores, @@ -249,11 +240,6 @@ impl TreeConfig { self.max_execute_block_batch_size } - /// Return the maximum proof task concurrency. - pub const fn max_proof_task_concurrency(&self) -> u64 { - self.max_proof_task_concurrency - } - /// Return whether the multiproof task chunking is enabled. pub const fn multiproof_chunking_enabled(&self) -> bool { self.multiproof_chunking_enabled @@ -420,16 +406,6 @@ impl TreeConfig { self } - /// Setter for maximum number of concurrent proof tasks. - pub const fn with_max_proof_task_concurrency( - mut self, - max_proof_task_concurrency: u64, - ) -> Self { - assert!(max_proof_task_concurrency > 0, "max_proof_task_concurrency must be at least 1"); - self.max_proof_task_concurrency = max_proof_task_concurrency; - self - } - /// Setter for whether multiproof task should chunk proof targets. pub const fn with_multiproof_chunking_enabled( mut self, diff --git a/crates/engine/tree/src/tree/payload_processor/mod.rs b/crates/engine/tree/src/tree/payload_processor/mod.rs index d2e48a49899..6d2a8ac0456 100644 --- a/crates/engine/tree/src/tree/payload_processor/mod.rs +++ b/crates/engine/tree/src/tree/payload_processor/mod.rs @@ -200,7 +200,6 @@ where ); let storage_worker_count = config.storage_worker_count(); let account_worker_count = config.account_worker_count(); - let max_proof_task_concurrency = config.max_proof_task_concurrency() as usize; let proof_handle = ProofWorkerHandle::new( self.executor.handle().clone(), consistent_view, @@ -209,15 +208,11 @@ where account_worker_count, ); - // We set it to half of the proof task concurrency, because often for each multiproof we - // spawn one Tokio task for the account proof, and one Tokio task for the storage proof. - let max_multi_proof_task_concurrency = max_proof_task_concurrency / 2; let multi_proof_task = MultiProofTask::new( state_root_config, self.executor.clone(), proof_handle.clone(), to_sparse_trie, - max_multi_proof_task_concurrency, config.multiproof_chunking_enabled().then_some(config.multiproof_chunk_size()), ); diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index a528b759570..9b16c08b70a 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -34,6 +34,10 @@ use std::{ }; use tracing::{debug, error, trace}; +/// Default upper bound for inflight multiproof calculations. These would be sitting in the queue +/// waiting to +pub const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; + /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state. #[derive(Default, Debug)] @@ -338,8 +342,8 @@ impl MultiproofInput { /// availability has been signaled. #[derive(Debug)] pub struct MultiproofManager { - /// Maximum number of concurrent calculations. - max_concurrent: usize, + /// Maximum number of proof calculations allowed to be inflight at once. + inflight_limit: usize, /// Currently running calculations. inflight: usize, /// Queued calculations. @@ -370,11 +374,10 @@ impl MultiproofManager { executor: WorkloadExecutor, metrics: MultiProofTaskMetrics, proof_worker_handle: ProofWorkerHandle, - max_concurrent: usize, ) -> Self { Self { - pending: VecDeque::with_capacity(max_concurrent), - max_concurrent, + pending: VecDeque::with_capacity(DEFAULT_MULTIPROOF_INFLIGHT_LIMIT), + inflight_limit: DEFAULT_MULTIPROOF_INFLIGHT_LIMIT, executor, inflight: 0, metrics, @@ -383,12 +386,11 @@ impl MultiproofManager { } } - const fn is_full(&self) -> bool { - self.inflight >= self.max_concurrent + fn is_full(&self) -> bool { + self.inflight >= self.inflight_limit } - /// Spawns a new multiproof calculation or enqueues it for later if - /// `max_concurrent` are already inflight. + /// Spawns a new multiproof calculation or enqueues it if the inflight limit is reached. fn spawn_or_queue(&mut self, input: PendingMultiproofTask) { // If there are no proof targets, we can just send an empty multiproof back immediately if input.proof_targets_is_empty() { @@ -685,7 +687,6 @@ impl MultiProofTask { executor: WorkloadExecutor, proof_worker_handle: ProofWorkerHandle, to_sparse_trie: Sender, - max_concurrency: usize, chunk_size: Option, ) -> Self { let (tx, rx) = channel(); @@ -704,7 +705,6 @@ impl MultiProofTask { executor, metrics.clone(), proof_worker_handle, - max_concurrency, ), metrics, } @@ -1231,7 +1231,7 @@ mod tests { ProofWorkerHandle::new(executor.handle().clone(), consistent_view, task_ctx, 1, 1); let channel = channel(); - MultiProofTask::new(config, executor, proof_handle, channel.0, 1, None) + MultiProofTask::new(config, executor, proof_handle, channel.0, Some(1)) } #[test] diff --git a/crates/node/core/src/args/engine.rs b/crates/node/core/src/args/engine.rs index c82b1b03a15..29535f2c1df 100644 --- a/crates/node/core/src/args/engine.rs +++ b/crates/node/core/src/args/engine.rs @@ -4,8 +4,8 @@ use clap::Args; use reth_engine_primitives::{TreeConfig, DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE}; use crate::node_config::{ - DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, DEFAULT_MAX_PROOF_TASK_CONCURRENCY, - DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES, + DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, + DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES, }; /// Parameters for configuring the engine driver. @@ -63,10 +63,6 @@ pub struct EngineArgs { #[arg(long = "engine.accept-execution-requests-hash")] pub accept_execution_requests_hash: bool, - /// Configure the maximum number of concurrent proof tasks - #[arg(long = "engine.max-proof-task-concurrency", default_value_t = DEFAULT_MAX_PROOF_TASK_CONCURRENCY)] - pub max_proof_task_concurrency: u64, - /// Whether multiproof task should chunk proof targets. #[arg(long = "engine.multiproof-chunking", default_value = "true")] pub multiproof_chunking_enabled: bool, @@ -135,7 +131,6 @@ impl Default for EngineArgs { state_provider_metrics: false, cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, accept_execution_requests_hash: false, - max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY, multiproof_chunking_enabled: true, multiproof_chunk_size: DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE, reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES, @@ -162,7 +157,6 @@ impl EngineArgs { .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) - .with_max_proof_task_concurrency(self.max_proof_task_concurrency) .with_multiproof_chunking_enabled(self.multiproof_chunking_enabled) .with_multiproof_chunk_size(self.multiproof_chunk_size) .with_reserved_cpu_cores(self.reserved_cpu_cores) diff --git a/crates/node/core/src/node_config.rs b/crates/node/core/src/node_config.rs index e3b98f4bd0f..869f2da123d 100644 --- a/crates/node/core/src/node_config.rs +++ b/crates/node/core/src/node_config.rs @@ -34,8 +34,7 @@ use tracing::*; use crate::args::{EraArgs, MetricArgs}; pub use reth_engine_primitives::{ - DEFAULT_MAX_PROOF_TASK_CONCURRENCY, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, - DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES, + DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES, }; /// Default size of cross-block cache in megabytes. diff --git a/docs/cli/help.rs b/docs/cli/help.rs index 05e61eef740..0474d00e723 100755 --- a/docs/cli/help.rs +++ b/docs/cli/help.rs @@ -269,11 +269,6 @@ fn preprocess_help(s: &str) -> Cow<'_, str> { r"(rpc.max-tracing-requests \n.*\n.*\n.*\n.*\n.*)\[default: \d+\]", r"$1[default: ]", ), - // Handle engine.max-proof-task-concurrency dynamic default - ( - r"(engine\.max-proof-task-concurrency.*)\[default: \d+\]", - r"$1[default: ]", - ), // Handle engine.reserved-cpu-cores dynamic default ( r"(engine\.reserved-cpu-cores.*)\[default: \d+\]", diff --git a/docs/vocs/docs/pages/cli/reth/node.mdx b/docs/vocs/docs/pages/cli/reth/node.mdx index a752f76b019..591528710a8 100644 --- a/docs/vocs/docs/pages/cli/reth/node.mdx +++ b/docs/vocs/docs/pages/cli/reth/node.mdx @@ -840,11 +840,6 @@ Engine: --engine.accept-execution-requests-hash Enables accepting requests hash instead of an array of requests in `engine_newPayloadV4` - --engine.max-proof-task-concurrency - Configure the maximum number of concurrent proof tasks - - [default: 256] - --engine.multiproof-chunking Whether multiproof task should chunk proof targets @@ -1017,4 +1012,4 @@ Tracing: Defaults to TRACE if not specified. [default: TRACE] -``` \ No newline at end of file +``` From 46d030f9bb3caacdca316031ec528b8be5e4ee51 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 08:37:43 +0000 Subject: [PATCH 2/8] fmt --- crates/engine/tree/src/tree/payload_processor/multiproof.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 9b16c08b70a..1fdd952fe40 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -35,7 +35,7 @@ use std::{ use tracing::{debug, error, trace}; /// Default upper bound for inflight multiproof calculations. These would be sitting in the queue -/// waiting to +/// waiting to pub const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the From 59988b11b391836bfd54a7b4d21f434b22085cf1 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 08:42:51 +0000 Subject: [PATCH 3/8] clippy --- crates/engine/tree/src/tree/payload_processor/multiproof.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 1fdd952fe40..6896aa94848 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -386,7 +386,7 @@ impl MultiproofManager { } } - fn is_full(&self) -> bool { + const fn is_full(&self) -> bool { self.inflight >= self.inflight_limit } From 11bddf4ebe01e50d319a36416b5741b45b97cdf9 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 08:57:07 +0000 Subject: [PATCH 4/8] remove --- crates/engine/tree/src/tree/payload_processor/multiproof.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 6896aa94848..53694fd35ab 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -35,8 +35,8 @@ use std::{ use tracing::{debug, error, trace}; /// Default upper bound for inflight multiproof calculations. These would be sitting in the queue -/// waiting to -pub const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; +/// waiting to be processed. +const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state. From e4896e144c9cee0cc4ec532c0799e0bea56117fd Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 09:05:20 +0000 Subject: [PATCH 5/8] remove line break --- docs/vocs/docs/pages/cli/reth/node.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/vocs/docs/pages/cli/reth/node.mdx b/docs/vocs/docs/pages/cli/reth/node.mdx index 591528710a8..ca37568d3aa 100644 --- a/docs/vocs/docs/pages/cli/reth/node.mdx +++ b/docs/vocs/docs/pages/cli/reth/node.mdx @@ -1012,4 +1012,4 @@ Tracing: Defaults to TRACE if not specified. [default: TRACE] -``` +``` \ No newline at end of file From 941942484f55265a40cdcbc3477c8a3f264a23f4 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 10:35:32 +0000 Subject: [PATCH 6/8] perf: removed pending --- .../src/tree/payload_processor/multiproof.rs | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 53694fd35ab..b4e008f69fd 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -24,7 +24,7 @@ use reth_trie_parallel::{ root::ParallelStateRootError, }; use std::{ - collections::{BTreeMap, VecDeque}, + collections::BTreeMap, ops::DerefMut, sync::{ mpsc::{channel, Receiver, Sender}, @@ -34,10 +34,6 @@ use std::{ }; use tracing::{debug, error, trace}; -/// Default upper bound for inflight multiproof calculations. These would be sitting in the queue -/// waiting to be processed. -const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; - /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state. #[derive(Default, Debug)] @@ -337,17 +333,11 @@ impl MultiproofInput { } /// Manages concurrent multiproof calculations. -/// Takes care of not having more calculations in flight than a given maximum -/// concurrency, further calculation requests are queued and spawn later, after -/// availability has been signaled. +/// Takes care of spawning multiproof calculations and tracking in-flight work. #[derive(Debug)] pub struct MultiproofManager { - /// Maximum number of proof calculations allowed to be inflight at once. - inflight_limit: usize, /// Currently running calculations. inflight: usize, - /// Queued calculations. - pending: VecDeque, /// Executor for tasks executor: WorkloadExecutor, /// Handle to the proof worker pools (storage and account). @@ -376,8 +366,6 @@ impl MultiproofManager { proof_worker_handle: ProofWorkerHandle, ) -> Self { Self { - pending: VecDeque::with_capacity(DEFAULT_MULTIPROOF_INFLIGHT_LIMIT), - inflight_limit: DEFAULT_MULTIPROOF_INFLIGHT_LIMIT, executor, inflight: 0, metrics, @@ -386,11 +374,7 @@ impl MultiproofManager { } } - const fn is_full(&self) -> bool { - self.inflight >= self.inflight_limit - } - - /// Spawns a new multiproof calculation or enqueues it if the inflight limit is reached. + /// Spawns a new multiproof calculation for the provided input. fn spawn_or_queue(&mut self, input: PendingMultiproofTask) { // If there are no proof targets, we can just send an empty multiproof back immediately if input.proof_targets_is_empty() { @@ -402,12 +386,6 @@ impl MultiproofManager { return } - if self.is_full() { - self.pending.push_back(input); - self.metrics.pending_multiproofs_histogram.record(self.pending.len() as f64); - return; - } - self.spawn_multiproof_task(input); } @@ -416,11 +394,6 @@ impl MultiproofManager { fn on_calculation_complete(&mut self) { self.inflight = self.inflight.saturating_sub(1); self.metrics.inflight_multiproofs_histogram.record(self.inflight as f64); - - if let Some(input) = self.pending.pop_front() { - self.metrics.pending_multiproofs_histogram.record(self.pending.len() as f64); - self.spawn_multiproof_task(input); - } } /// Spawns a multiproof task, dispatching to `spawn_storage_proof` if the input is a storage @@ -606,8 +579,6 @@ impl MultiproofManager { pub(crate) struct MultiProofTaskMetrics { /// Histogram of inflight multiproofs. pub inflight_multiproofs_histogram: Histogram, - /// Histogram of pending multiproofs. - pub pending_multiproofs_histogram: Histogram, /// Histogram of the number of prefetch proof target accounts. pub prefetch_proof_targets_accounts_histogram: Histogram, From e121bc2f7c87aa974128b54f74d1d5e729a80dcb Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 10:43:29 +0000 Subject: [PATCH 7/8] Revert "perf: removed pending" This reverts commit 941942484f55265a40cdcbc3477c8a3f264a23f4. --- .../src/tree/payload_processor/multiproof.rs | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index b4e008f69fd..53694fd35ab 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -24,7 +24,7 @@ use reth_trie_parallel::{ root::ParallelStateRootError, }; use std::{ - collections::BTreeMap, + collections::{BTreeMap, VecDeque}, ops::DerefMut, sync::{ mpsc::{channel, Receiver, Sender}, @@ -34,6 +34,10 @@ use std::{ }; use tracing::{debug, error, trace}; +/// Default upper bound for inflight multiproof calculations. These would be sitting in the queue +/// waiting to be processed. +const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; + /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state. #[derive(Default, Debug)] @@ -333,11 +337,17 @@ impl MultiproofInput { } /// Manages concurrent multiproof calculations. -/// Takes care of spawning multiproof calculations and tracking in-flight work. +/// Takes care of not having more calculations in flight than a given maximum +/// concurrency, further calculation requests are queued and spawn later, after +/// availability has been signaled. #[derive(Debug)] pub struct MultiproofManager { + /// Maximum number of proof calculations allowed to be inflight at once. + inflight_limit: usize, /// Currently running calculations. inflight: usize, + /// Queued calculations. + pending: VecDeque, /// Executor for tasks executor: WorkloadExecutor, /// Handle to the proof worker pools (storage and account). @@ -366,6 +376,8 @@ impl MultiproofManager { proof_worker_handle: ProofWorkerHandle, ) -> Self { Self { + pending: VecDeque::with_capacity(DEFAULT_MULTIPROOF_INFLIGHT_LIMIT), + inflight_limit: DEFAULT_MULTIPROOF_INFLIGHT_LIMIT, executor, inflight: 0, metrics, @@ -374,7 +386,11 @@ impl MultiproofManager { } } - /// Spawns a new multiproof calculation for the provided input. + const fn is_full(&self) -> bool { + self.inflight >= self.inflight_limit + } + + /// Spawns a new multiproof calculation or enqueues it if the inflight limit is reached. fn spawn_or_queue(&mut self, input: PendingMultiproofTask) { // If there are no proof targets, we can just send an empty multiproof back immediately if input.proof_targets_is_empty() { @@ -386,6 +402,12 @@ impl MultiproofManager { return } + if self.is_full() { + self.pending.push_back(input); + self.metrics.pending_multiproofs_histogram.record(self.pending.len() as f64); + return; + } + self.spawn_multiproof_task(input); } @@ -394,6 +416,11 @@ impl MultiproofManager { fn on_calculation_complete(&mut self) { self.inflight = self.inflight.saturating_sub(1); self.metrics.inflight_multiproofs_histogram.record(self.inflight as f64); + + if let Some(input) = self.pending.pop_front() { + self.metrics.pending_multiproofs_histogram.record(self.pending.len() as f64); + self.spawn_multiproof_task(input); + } } /// Spawns a multiproof task, dispatching to `spawn_storage_proof` if the input is a storage @@ -579,6 +606,8 @@ impl MultiproofManager { pub(crate) struct MultiProofTaskMetrics { /// Histogram of inflight multiproofs. pub inflight_multiproofs_histogram: Histogram, + /// Histogram of pending multiproofs. + pub pending_multiproofs_histogram: Histogram, /// Histogram of the number of prefetch proof target accounts. pub prefetch_proof_targets_accounts_histogram: Histogram, From 081a204ede68c30841a84bae0151d35a3e1883db Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Tue, 21 Oct 2025 11:56:40 +0000 Subject: [PATCH 8/8] reduce to 128 as per default --- crates/engine/tree/src/tree/payload_processor/multiproof.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 53694fd35ab..e44ba7bb194 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -36,7 +36,7 @@ use tracing::{debug, error, trace}; /// Default upper bound for inflight multiproof calculations. These would be sitting in the queue /// waiting to be processed. -const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 256; +const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 128; /// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the /// state.