Skip to content

Conversation

yongkangc
Copy link
Member

@yongkangc yongkangc commented Oct 7, 2025

This PR add worker pooling to our existing proof generation. This PR starts by adding worker pooling to storage proofs, which allows us to reduce overhead from spawning the worker.

Core logic:

  1. Determine workers based on parallelism
  2. Spawn x workers each with its own tx
  3. Queue storage proofs via crossbeam channels to the workers

Issues closed:

References:

Next Steps:

  • Moving Account and Blinded nodes to adopt the same infrastructure

Benches:

Reth4 Mainnet
image

- Added configuration for maximum and minimum storage proof workers.
- Implemented a worker pool for processing storage proof tasks, improving efficiency by reusing transactions.
- Updated `ProofTaskManager` to handle storage proof tasks via a dedicated channel.
- Enhanced metrics to track storage proof requests and fallback scenarios.
- Adjusted existing tests to accommodate the new storage worker functionality.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces worker pooling for storage proof generation to improve multiproof performance through parallel processing. The implementation adds dedicated storage workers with long-lived database transactions while maintaining backward compatibility.

  • Introduces worker pool architecture with pre-spawned workers for storage proof computation
  • Replaces ProofTaskManager internal task handling with mixed worker pool and on-demand execution
  • Adds crossbeam channels for efficient worker communication and transaction budget allocation

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/trie/parallel/src/proof_task_metrics.rs Adds metrics tracking for storage proof workers and fallback scenarios
crates/trie/parallel/src/proof_task.rs Major refactor introducing worker pool architecture and new task routing logic
crates/trie/parallel/src/proof.rs Updates test to use new constructor signature with storage worker count
crates/trie/parallel/Cargo.toml Adds crossbeam-channel dependency for worker communication
crates/engine/tree/src/tree/payload_processor/multiproof.rs Updates test configuration for new worker pool parameters
crates/engine/tree/src/tree/payload_processor/mod.rs Integrates storage worker configuration into payload processor
crates/engine/primitives/src/config.rs Adds configuration options for storage proof worker pool sizing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Enhanced documentation for `StorageProofJob` to clarify its current unused status and potential for future type-safe design.
- Updated comments in `ProofTaskManager` regarding the handling of on-demand tasks and the possibility of refactoring to a more type-safe enum.
- Improved logging for worker pool disconnection scenarios, emphasizing fallback to on-demand execution.
…clarity

- Updated comments in `ProofTaskManager` to enhance clarity regarding on-demand transaction handling and queue management.
- Renamed `pending_on_demand` to `on_demand_queue` for better understanding of its purpose.
- Adjusted the `new` function documentation to reflect the correct allocation of concurrency budget between storage workers and on-demand transactions.
- Improved the `queue_proof_task` method to use the new queue name.
…ement

- Removed the unused `OnDemandTask` enum and updated comments in `ProofTaskManager` to clarify the distinction between storage worker pool and on-demand execution.
- Enhanced documentation to better describe the public interface and task submission process.
- Improved clarity regarding transaction handling and execution paths for proof requests.
- Eliminated the `storage_proof_workers` field and related constants from `TreeConfig`.
- Updated the default implementation and related methods to reflect the removal, streamlining the configuration structure.
@yongkangc yongkangc marked this pull request as ready for review October 7, 2025 07:36
@yongkangc yongkangc requested a review from Copilot October 7, 2025 07:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Improved comments in `ProofTaskManager` and related functions for better clarity on task management and processing.
- Updated queue capacity calculation to use 4x buffering, reducing fallback to slower on-demand execution during burst loads.
- Removed redundant variable assignments to streamline the code.
@yongkangc
Copy link
Member Author

yongkangc commented Oct 7, 2025

Benching at 3fb97c6 on reth4 mainnet

image image

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 7, 2025
yongkangc and others added 3 commits October 8, 2025 21:14
Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
@yongkangc yongkangc force-pushed the yk/worker_pool_storage_2 branch from 3cd7546 to f823c6b Compare October 8, 2025 13:25
@yongkangc
Copy link
Member Author

latency_comparison (1)

Bench on Base cc @mattsse

@yongkangc yongkangc added this pull request to the merge queue Oct 9, 2025
@yongkangc yongkangc removed this pull request from the merge queue due to a manual request Oct 9, 2025
@jenpaff jenpaff moved this from In Progress to Blocked in Reth Tracker Oct 9, 2025
@yongkangc yongkangc requested a review from klkvr as a code owner October 9, 2025 15:24
@yongkangc yongkangc force-pushed the yk/worker_pool_storage_2 branch from a8fef7e to 4ca404e Compare October 9, 2025 15:26
@yongkangc yongkangc added this pull request to the merge queue Oct 10, 2025
Merged via the queue into main with commit 397a30d Oct 10, 2025
45 of 49 checks passed
@yongkangc yongkangc deleted the yk/worker_pool_storage_2 branch October 10, 2025 08:15
@github-project-automation github-project-automation bot moved this from Blocked to Done in Reth Tracker Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants