-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor(trie): remove proof task manager #18934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
- 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.
…Metrics and ProofTaskTrieMetrics
…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.
- 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.
Co-authored-by: Brian Picciano <[email protected]>
Co-authored-by: Brian Picciano <[email protected]>
…ursor factories - Introduced pre-created cursor factories in `storage_worker_loop` to reduce overhead during proof computation. - Updated `compute_storage_proof` to accept cursor factories as parameters, enhancing efficiency and clarity. - Improved logging to provide better insights into proof task calculations.
- not change the logic for pending_tasks and proof_tasks_txs (on-demand proofs) and just continue using it for the BlindedAccountNode requests, but start using dedicated storage workers for StorageProof and BlindedStorageNode requests
Co-authored-by: Copilot <[email protected]>
- Added a function to determine the default number of storage worker threads based on available parallelism. - Updated TreeConfig to include a storage_worker_count field, initialized with the default value. - Modified payload processor to utilize the new storage_worker_count instead of a hardcoded value.
There was a problem hiding this 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 7 out of 7 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
left some suggestions, iirc additional changes to the worker pool are planned anyway and we could tackle those separately
let _ = self.proof_task_handle.queue_task(ProofTaskKind::StorageProof(input, sender)); | ||
receiver | ||
self.proof_task_handle | ||
.queue_storage_proof(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename these after we merge, because I find queue
very confusing here because this only sends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats true -> should rename it as send_task
for worker_id in 0..storage_worker_count { | ||
let provider_ro = view.provider_ro()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is still something we pay for upfront, meaning this isn't done in the background
this does mean it currently takes more time to set this up if we bump the worker count?
I think ideally we return the channels right away and do this setup in the background so that we don't block here:
let proof_handle = match ProofTaskManagerHandle::new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense, good idea for us to do in bg
for worker_id in 0..account_worker_count { | ||
let provider_ro = view.provider_ro()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
/// eliminating the need for a routing thread. All handles share reference-counted | ||
/// channels, and workers shut down gracefully when all handles are dropped. | ||
#[derive(Debug, Clone)] | ||
pub struct ProofTaskManagerHandle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this a tiny bit confusing that we have a ProofTaskManagerHandle
, but no ProofTaskManager
, as there's usually a pattern of having a fn handle(&self) -> Handle
method. Not necessary to address in this PR, can be a followup.
self.account_work_tx | ||
.send(AccountWorkerJob::AccountMultiproof { input, result_sender: tx }) | ||
.map_err(|_| { | ||
ProviderError::other(std::io::Error::other("account workers unavailable")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would also like to address this in a followup cleanup, this feels like misuse of std::io::Error
let (storage_work_tx, storage_work_rx) = unbounded::<StorageWorkerJob>(); | ||
let (account_work_tx, account_work_rx) = unbounded::<AccountWorkerJob>(); | ||
|
||
tracing::info!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracing::info!( | |
tracing::debug!( |
Context:
closes: #18801
impact:
run()
loop threadreference PRs: