Commit Graph

11785 Commits

Author SHA1 Message Date
Yong Kang
42ceeddef7 fix: prevent active_handles underflow in ProofTaskManagerHandle
- Added a debug assertion to ensure active_handles does not underflow when dropping a ProofTaskManagerHandle.
- Implemented metrics recording to flush before exit when the last handle is dropped, enhancing monitoring capabilities.
2025-10-10 10:34:14 +00:00
Yong Kang
0b18f6488a feat: introduce minimum worker count configuration
- Added a constant `MIN_WORKER_COUNT` to enforce a minimum number of workers for storage and account proof tasks.
- Updated `default_storage_worker_count` and `default_account_worker_count` functions to utilize the new minimum constraint.
- Enhanced setter methods in `TreeConfig` to ensure worker counts do not fall below the minimum.
- Modified command-line argument parsing to validate worker counts against the minimum requirement.
2025-10-10 10:26:56 +00:00
Yong Kang
d44180dc1b fix comment 2025-10-10 10:25:49 +00:00
Yong Kang
ed45ebda8a refactor: yeet proof task manager 2025-10-10 10:18:58 +00:00
Yong Kang
3516451740 refactor: update proof task management to use spawn_proof_workers
- Replaced the ProofTaskManager with a new spawn_proof_workers function for better clarity and maintainability.
- Updated related code to utilize the new function, simplifying the worker spawning process.
- Enhanced metrics tracking for storage and account proof requests, ensuring thread-safe operations.
- Improved error handling and code structure across proof task implementations.
2025-10-10 09:49:05 +00:00
Yong Kang
0a88a18203 fmt 2025-10-10 08:16:45 +00:00
Yong Kang
47da382d01 clippy 2025-10-10 08:12:09 +00:00
Yong Kang
11130c7fce refactor: simplify MultiProofConfig and related structures
- Removed the generic Factory type from MultiProofConfig and related structs, streamlining their definitions and improving code clarity.
- Updated methods to reflect the removal of the Factory type, enhancing maintainability.
- Adjusted the implementation of PendingMultiproofTask and its associated methods to eliminate unnecessary type parameters, simplifying the codebase.
2025-10-10 08:01:38 +00:00
Yong Kang
444b24c7e9 refactor: remove unused Factory type from proof tests
- Eliminated the Factory type definition from the proof tests, simplifying the code structure.
- This change contributes to improved clarity and maintainability of the test implementation.
2025-10-10 05:59:30 +00:00
Yong Kang
d5fedd80ce removing from test 2025-10-10 05:59:03 +00:00
Yong Kang
47398ce49a refactor: simplify ParallelProof struct by removing generic Factory type
- Removed the Factory type parameter from the ParallelProof struct, streamlining its definition and implementation.
- Updated the constructor and related methods to reflect this change, enhancing code clarity and maintainability.
- Eliminated unused PhantomData field, reducing complexity in the struct's design.
2025-10-10 05:57:19 +00:00
Yong Kang
f23cfab54f refactor: addressed dan's comment on making structs that encapsulate loops:
- an account worker / loop
- a storage worker / loop

- streamline worker spawning functions in ProofTaskManager

- Consolidated worker spawning logic by renaming and simplifying the `spawn_worker_pool` function to `spawn_storage_workers` and `spawn_account_workers`, enhancing clarity and maintainability.
- Removed the `WorkerType` enum and associated logic, as the worker type is now inferred from the context, reducing complexity.
- Updated comments to better describe the purpose and parameters of the new functions, improving code documentation.
2025-10-10 04:56:15 +00:00
YK
5a69925ce0 Merge branch 'yk/worker_pool_storage_2' into yk/worker_pool_acc 2025-10-10 12:41:58 +08:00
Yong Kang
1bc2862d17 move the AccountMultiproofParams struct to just below AccountMultiproofInput so all account multiproof types live together. 2025-10-10 04:35:16 +00:00
Yong Kang
aae5c7a5ac refactor: simplify account multiproof function parameters
- Introduced `AccountMultiproofParams` struct to encapsulate parameters for building account multiproofs, reducing the number of arguments in the `build_account_multiproof_with_storage_roots` function.
- Updated the `account_worker_loop` to use the new struct, improving code readability and maintainability.
2025-10-10 04:32:58 +00:00
Yong Kang
05f177adf9 added a todo 2025-10-10 04:24:41 +00:00
Yong Kang
5d109344c0 feat: add storage and account worker count configuration options
- Introduced `storage_worker_count` and `account_worker_count` fields in `EngineArgs` to allow configuration of the number of workers in the Tokio blocking pool.
- Updated the `tree_config` method to incorporate these new fields, enhancing flexibility in managing proof worker resources.
- Updated CLI documentation to reflect the new configuration options for improved user guidance.
2025-10-10 04:24:25 +00:00
Yong Kang
8e64738b03 docs: clarify storage-worker-count uses Tokio blocking pool 2025-10-10 00:21:52 +00:00
Yong Kang
4aba3de076 docs: update CLI reference for storage-worker-count flag 2025-10-10 00:19:27 +00:00
Yong Kang
d66ed61397 cli flag for storage 2025-10-09 14:57:53 +00:00
Yong Kang
4ca404e517 bump up workers 2025-10-09 14:35:13 +00:00
Yong Kang
2091f0d18f expect workers to be avaliable 2025-10-09 08:05:14 +00:00
Yong Kang
19a9e8b1d0 comment 2025-10-09 07:45:26 +00:00
Yong Kang
4596366257 refactor: clarify comments for proof task handles in MultiproofManager
- Updated comments for `proof_task_handle` parameters in the `MultiproofManager` initialization to specify their roles for storage and account proof workers, improving code clarity and maintainability.
2025-10-09 07:40:56 +00:00
Yong Kang
9e177f44a5 feat: add default account worker count for optimized I/O-bound coordination
- Introduced a new function `default_account_worker_count` to calculate the default number of account worker threads, set to 1.5 times the storage worker count.
- Updated the `TreeConfig` implementation to use the new account worker count function, enhancing performance for I/O-bound tasks related to storage proof collection and account trie traversal.
2025-10-09 05:33:05 +00:00
Yong Kang
84ad2180e3 refactor: update account worker loop to use crossbeam sender for storage jobs
- Replaced the `storage_proof_handle` parameter with `storage_work_tx` in the `account_worker_loop` function to facilitate direct communication with the storage worker queue.
- Modified the `queue_storage_proofs` function to accept a mutable reference to `storage_prefix_sets`, improving efficiency by avoiding unnecessary clones.
- Enhanced the initialization of `collected_decoded_storages` to use pre-allocated capacity, optimizing memory usage during proof collection.
2025-10-09 05:22:25 +00:00
Yong Kang
b4d109bfa0 clippy 2025-10-09 05:20:45 +00:00
Yong Kang
5647e22989 avoid extra alloc on map
-   Before this change the code did:

  StorageRootTargets::new(
      prefix_sets.account_prefix_set.iter().map(|n|
  B256::from_slice(&nibbles.pack())),
      prefix_sets.storage_prefix_sets.clone(),
  ).len()

  StorageRootTargets::new(..) builds a brand-new
  B256Map<PrefixSet> by:

  - cloning every entry in storage_prefix_sets (each PrefixSet can
    hold dozens of nibble prefixes), and
  - allocating a fresh B256Map to hold them.

- We only needed the resulting length, so those clones/allocations
  were immediately thrown away.
2025-10-09 05:16:04 +00:00
Yong Kang
e427485e16 Removed the unused _proof_tx parameter from queue_storage_proofs 2025-10-09 04:39:23 +00:00
Yong Kang
3c00e98302 refactor: use receiver to allow Account worker and storage workers run in parallel
- replace standard mpsc channels with crossbeam channels in `ProofTaskManager`

- Updated `proof_task_rx` and `proof_task_tx` to use `CrossbeamReceiver` and `CrossbeamSender` for improved performance and non-blocking behavior.
- Renamed `collect_storage_proofs` to `queue_storage_proofs` to better reflect its functionality of returning receivers for storage proofs.
- Enhanced documentation to clarify the interleaved parallelism between account trie traversal and storage proof computation.
2025-10-09 04:08:17 +00:00
Yong Kang
a654cf8d73 rm clone from StorageProofInput 2025-10-09 03:31:49 +00:00
Yong Kang
1bbfc7c33d clippy 2025-10-09 02:40:50 +00:00
YK
498cd20213 Merge branch 'yk/worker_pool_storage_2' into yk/worker_pool_acc 2025-10-09 10:05:13 +08:00
Yong Kang
e418bb1496 refactor: improve documentation for proof task handles in MultiproofManager
- Updated comments for `storage_proof_task_handle` and `account_proof_task_handle` to clarify their roles in managing proof tasks.
- Adjusted method calls to use the updated handle references, enhancing code readability and maintainability.
2025-10-09 02:01:29 +00:00
Yong Kang
7df34889c2 refactor: simplify ProofTaskManager by removing generic type parameter
- Removed the generic type parameter `Factory` from the `ProofTaskManager` struct and its implementation, streamlining the code.
- Updated the `new` and `spawn_worker_pool` methods to maintain functionality while simplifying type handling.
- Enhanced clarity and reduced complexity in the proof task management logic.
2025-10-09 02:01:19 +00:00
Yong Kang
3b815f691e refactor: rename storage proof task handle for clarity
- Updated the field name from `storage_proof_task_handle` to `proof_task_handle` in the `ParallelProof` struct to better reflect its purpose.
- Adjusted related method signatures and internal references to maintain consistency throughout the codebase.
2025-10-09 01:59:49 +00:00
Yong Kang
5e1ca830d2 fmt 2025-10-09 01:59:19 +00:00
Yong Kang
14b6356868 refactor: remove generic type parameter from ProofTaskManagerHandle
- Removed the generic type parameter from `ProofTaskManagerHandle` and related structures to streamline the code.
- Updated the `MultiproofManager` and `ProofTaskManager` to use the simplified handle, enhancing clarity and reducing complexity.
- Adjusted method signatures and internal logic to accommodate the changes while maintaining functionality.
2025-10-09 01:51:37 +00:00
Yong Kang
dc5ba157d6 moved build_account_multiproof_with_storage_roots to prooftask.rs
- brian
2025-10-09 01:31:50 +00:00
Yong Kang
6d413528a0 fix 2025-10-08 13:30:03 +00:00
Yong Kang
7f9ec065b2 fmt, clipy 2025-10-08 13:28:30 +00:00
Yong Kang
9c08aedb4c Refactor error handling in StorageWorkerJob to use structured error types 2025-10-08 13:28:21 +00:00
Yong Kang
f823c6bcd9 Refactor error handling in StorageWorkerJob to use a consistent error message format 2025-10-08 13:17:40 +00:00
YK
f7cd93fb85 Update crates/trie/parallel/src/proof_task.rs
Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
2025-10-08 21:14:58 +08:00
YK
7efff3d4e5 Update crates/trie/parallel/src/proof_task.rs
Co-authored-by: Alexey Shekhirin <5773434+shekhirin@users.noreply.github.com>
2025-10-08 21:14:37 +08:00
Yong Kang
d0e2ba1efe removed generic based on brian's suggestion 2025-10-08 13:08:42 +00:00
Yong Kang
9fa34b02fe fmt 2025-10-08 13:06:51 +00:00
Yong Kang
d6401abba1 fix rebase conflict 2025-10-08 13:06:17 +00:00
Yong Kang
49410719eb rm comment 2025-10-08 13:01:45 +00:00
Yong Kang
e51707a62c refactor: simplify error handling in proof task management
- Removed the `send_worker_unavailable_error` method from both `StorageWorkerJob` and `AccountWorkerJob` enums to streamline error handling.
- Updated task dispatching logic in `ProofTaskMessage` to ensure that errors are handled more directly without the need for separate error sending methods.
- Enhanced clarity and maintainability of the code by reducing redundancy in error management.
2025-10-08 13:01:45 +00:00