Skip to content

Commit 60e3ede

Browse files
authored
refactor: decouple max proof task concurrency from inflight proof limits (#19171)
1 parent e810df9 commit 60e3ede

File tree

7 files changed

+14
-60
lines changed

7 files changed

+14
-60
lines changed

crates/engine/primitives/src/config.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ pub const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2;
66
/// How close to the canonical head we persist blocks.
77
pub const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 0;
88

9-
/// Default maximum concurrency for on-demand proof tasks (blinded nodes)
10-
pub const DEFAULT_MAX_PROOF_TASK_CONCURRENCY: u64 = 256;
11-
129
/// Minimum number of workers we allow configuring explicitly.
1310
pub const MIN_WORKER_COUNT: usize = 32;
1411

@@ -102,8 +99,6 @@ pub struct TreeConfig {
10299
cross_block_cache_size: u64,
103100
/// Whether the host has enough parallelism to run state root task.
104101
has_enough_parallelism: bool,
105-
/// Maximum number of concurrent proof tasks
106-
max_proof_task_concurrency: u64,
107102
/// Whether multiproof task should chunk proof targets.
108103
multiproof_chunking_enabled: bool,
109104
/// Multiproof task chunk size for proof targets.
@@ -153,7 +148,6 @@ impl Default for TreeConfig {
153148
state_provider_metrics: false,
154149
cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE,
155150
has_enough_parallelism: has_enough_parallelism(),
156-
max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
157151
multiproof_chunking_enabled: true,
158152
multiproof_chunk_size: DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE,
159153
reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES,
@@ -184,7 +178,6 @@ impl TreeConfig {
184178
state_provider_metrics: bool,
185179
cross_block_cache_size: u64,
186180
has_enough_parallelism: bool,
187-
max_proof_task_concurrency: u64,
188181
multiproof_chunking_enabled: bool,
189182
multiproof_chunk_size: usize,
190183
reserved_cpu_cores: usize,
@@ -196,7 +189,6 @@ impl TreeConfig {
196189
storage_worker_count: usize,
197190
account_worker_count: usize,
198191
) -> Self {
199-
assert!(max_proof_task_concurrency > 0, "max_proof_task_concurrency must be at least 1");
200192
Self {
201193
persistence_threshold,
202194
memory_block_buffer_target,
@@ -210,7 +202,6 @@ impl TreeConfig {
210202
state_provider_metrics,
211203
cross_block_cache_size,
212204
has_enough_parallelism,
213-
max_proof_task_concurrency,
214205
multiproof_chunking_enabled,
215206
multiproof_chunk_size,
216207
reserved_cpu_cores,
@@ -249,11 +240,6 @@ impl TreeConfig {
249240
self.max_execute_block_batch_size
250241
}
251242

252-
/// Return the maximum proof task concurrency.
253-
pub const fn max_proof_task_concurrency(&self) -> u64 {
254-
self.max_proof_task_concurrency
255-
}
256-
257243
/// Return whether the multiproof task chunking is enabled.
258244
pub const fn multiproof_chunking_enabled(&self) -> bool {
259245
self.multiproof_chunking_enabled
@@ -420,16 +406,6 @@ impl TreeConfig {
420406
self
421407
}
422408

423-
/// Setter for maximum number of concurrent proof tasks.
424-
pub const fn with_max_proof_task_concurrency(
425-
mut self,
426-
max_proof_task_concurrency: u64,
427-
) -> Self {
428-
assert!(max_proof_task_concurrency > 0, "max_proof_task_concurrency must be at least 1");
429-
self.max_proof_task_concurrency = max_proof_task_concurrency;
430-
self
431-
}
432-
433409
/// Setter for whether multiproof task should chunk proof targets.
434410
pub const fn with_multiproof_chunking_enabled(
435411
mut self,

crates/engine/tree/src/tree/payload_processor/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ where
207207
);
208208
let storage_worker_count = config.storage_worker_count();
209209
let account_worker_count = config.account_worker_count();
210-
let max_proof_task_concurrency = config.max_proof_task_concurrency() as usize;
211210
let proof_handle = ProofWorkerHandle::new(
212211
self.executor.handle().clone(),
213212
consistent_view,
@@ -216,15 +215,11 @@ where
216215
account_worker_count,
217216
);
218217

219-
// We set it to half of the proof task concurrency, because often for each multiproof we
220-
// spawn one Tokio task for the account proof, and one Tokio task for the storage proof.
221-
let max_multi_proof_task_concurrency = max_proof_task_concurrency / 2;
222218
let multi_proof_task = MultiProofTask::new(
223219
state_root_config,
224220
self.executor.clone(),
225221
proof_handle.clone(),
226222
to_sparse_trie,
227-
max_multi_proof_task_concurrency,
228223
config.multiproof_chunking_enabled().then_some(config.multiproof_chunk_size()),
229224
);
230225

crates/engine/tree/src/tree/payload_processor/multiproof.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ use std::{
3434
};
3535
use tracing::{debug, error, instrument, trace};
3636

37+
/// Default upper bound for inflight multiproof calculations. These would be sitting in the queue
38+
/// waiting to be processed.
39+
const DEFAULT_MULTIPROOF_INFLIGHT_LIMIT: usize = 128;
40+
3741
/// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the
3842
/// state.
3943
#[derive(Default, Debug)]
@@ -338,8 +342,8 @@ impl MultiproofInput {
338342
/// availability has been signaled.
339343
#[derive(Debug)]
340344
pub struct MultiproofManager {
341-
/// Maximum number of concurrent calculations.
342-
max_concurrent: usize,
345+
/// Maximum number of proof calculations allowed to be inflight at once.
346+
inflight_limit: usize,
343347
/// Currently running calculations.
344348
inflight: usize,
345349
/// Queued calculations.
@@ -370,11 +374,10 @@ impl MultiproofManager {
370374
executor: WorkloadExecutor,
371375
metrics: MultiProofTaskMetrics,
372376
proof_worker_handle: ProofWorkerHandle,
373-
max_concurrent: usize,
374377
) -> Self {
375378
Self {
376-
pending: VecDeque::with_capacity(max_concurrent),
377-
max_concurrent,
379+
pending: VecDeque::with_capacity(DEFAULT_MULTIPROOF_INFLIGHT_LIMIT),
380+
inflight_limit: DEFAULT_MULTIPROOF_INFLIGHT_LIMIT,
378381
executor,
379382
inflight: 0,
380383
metrics,
@@ -384,11 +387,10 @@ impl MultiproofManager {
384387
}
385388

386389
const fn is_full(&self) -> bool {
387-
self.inflight >= self.max_concurrent
390+
self.inflight >= self.inflight_limit
388391
}
389392

390-
/// Spawns a new multiproof calculation or enqueues it for later if
391-
/// `max_concurrent` are already inflight.
393+
/// Spawns a new multiproof calculation or enqueues it if the inflight limit is reached.
392394
fn spawn_or_queue(&mut self, input: PendingMultiproofTask) {
393395
// If there are no proof targets, we can just send an empty multiproof back immediately
394396
if input.proof_targets_is_empty() {
@@ -685,7 +687,6 @@ impl MultiProofTask {
685687
executor: WorkloadExecutor,
686688
proof_worker_handle: ProofWorkerHandle,
687689
to_sparse_trie: Sender<SparseTrieUpdate>,
688-
max_concurrency: usize,
689690
chunk_size: Option<usize>,
690691
) -> Self {
691692
let (tx, rx) = channel();
@@ -704,7 +705,6 @@ impl MultiProofTask {
704705
executor,
705706
metrics.clone(),
706707
proof_worker_handle,
707-
max_concurrency,
708708
),
709709
metrics,
710710
}
@@ -1239,7 +1239,7 @@ mod tests {
12391239
ProofWorkerHandle::new(executor.handle().clone(), consistent_view, task_ctx, 1, 1);
12401240
let channel = channel();
12411241

1242-
MultiProofTask::new(config, executor, proof_handle, channel.0, 1, None)
1242+
MultiProofTask::new(config, executor, proof_handle, channel.0, Some(1))
12431243
}
12441244

12451245
#[test]

crates/node/core/src/args/engine.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use clap::Args;
44
use reth_engine_primitives::{TreeConfig, DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE};
55

66
use crate::node_config::{
7-
DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
8-
DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES,
7+
DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
8+
DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES,
99
};
1010

1111
/// Parameters for configuring the engine driver.
@@ -63,10 +63,6 @@ pub struct EngineArgs {
6363
#[arg(long = "engine.accept-execution-requests-hash")]
6464
pub accept_execution_requests_hash: bool,
6565

66-
/// Configure the maximum number of concurrent proof tasks
67-
#[arg(long = "engine.max-proof-task-concurrency", default_value_t = DEFAULT_MAX_PROOF_TASK_CONCURRENCY)]
68-
pub max_proof_task_concurrency: u64,
69-
7066
/// Whether multiproof task should chunk proof targets.
7167
#[arg(long = "engine.multiproof-chunking", default_value = "true")]
7268
pub multiproof_chunking_enabled: bool,
@@ -135,7 +131,6 @@ impl Default for EngineArgs {
135131
state_provider_metrics: false,
136132
cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB,
137133
accept_execution_requests_hash: false,
138-
max_proof_task_concurrency: DEFAULT_MAX_PROOF_TASK_CONCURRENCY,
139134
multiproof_chunking_enabled: true,
140135
multiproof_chunk_size: DEFAULT_MULTIPROOF_TASK_CHUNK_SIZE,
141136
reserved_cpu_cores: DEFAULT_RESERVED_CPU_CORES,
@@ -162,7 +157,6 @@ impl EngineArgs {
162157
.with_state_provider_metrics(self.state_provider_metrics)
163158
.with_always_compare_trie_updates(self.state_root_task_compare_updates)
164159
.with_cross_block_cache_size(self.cross_block_cache_size * 1024 * 1024)
165-
.with_max_proof_task_concurrency(self.max_proof_task_concurrency)
166160
.with_multiproof_chunking_enabled(self.multiproof_chunking_enabled)
167161
.with_multiproof_chunk_size(self.multiproof_chunk_size)
168162
.with_reserved_cpu_cores(self.reserved_cpu_cores)

crates/node/core/src/node_config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use tracing::*;
3434

3535
use crate::args::{EraArgs, MetricArgs};
3636
pub use reth_engine_primitives::{
37-
DEFAULT_MAX_PROOF_TASK_CONCURRENCY, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
38-
DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES,
37+
DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_RESERVED_CPU_CORES,
3938
};
4039

4140
/// Default size of cross-block cache in megabytes.

docs/cli/help.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,6 @@ fn preprocess_help(s: &str) -> Cow<'_, str> {
269269
r"(rpc.max-tracing-requests <COUNT>\n.*\n.*\n.*\n.*\n.*)\[default: \d+\]",
270270
r"$1[default: <NUM CPU CORES-2>]",
271271
),
272-
// Handle engine.max-proof-task-concurrency dynamic default
273-
(
274-
r"(engine\.max-proof-task-concurrency.*)\[default: \d+\]",
275-
r"$1[default: <DYNAMIC: CPU cores * 8>]",
276-
),
277272
// Handle engine.reserved-cpu-cores dynamic default
278273
(
279274
r"(engine\.reserved-cpu-cores.*)\[default: \d+\]",

docs/vocs/docs/pages/cli/reth/node.mdx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,6 @@ Engine:
840840
--engine.accept-execution-requests-hash
841841
Enables accepting requests hash instead of an array of requests in `engine_newPayloadV4`
842842
843-
--engine.max-proof-task-concurrency <MAX_PROOF_TASK_CONCURRENCY>
844-
Configure the maximum number of concurrent proof tasks
845-
846-
[default: 256]
847-
848843
--engine.multiproof-chunking
849844
Whether multiproof task should chunk proof targets
850845

0 commit comments

Comments
 (0)