refactor(trie): improve proof task handle documentation

- Updated the documentation for `new_proof_task_handle` to clarify its purpose and functionality.
- Refined the logic for determining `queue_capacity` and `worker_count` to ensure proper initialization of the worker pool.
- Removed outdated comments regarding transaction pool resource management for clarity.
This commit is contained in:
Yong Kang
2025-10-07 05:12:44 +00:00
parent 79485d7ca9
commit 072a4fd2ca
2 changed files with 4 additions and 11 deletions

View File

@@ -500,7 +500,6 @@ mod tests {
assert_eq!(parallel_result, sequential_result_decoded);
// Drop the handle to release transaction pool resources
// Note: No manager loop to join in the new design - handle manages lifecycle via Drop
drop(proof_task_handle);
}
}

View File

@@ -49,11 +49,7 @@ type ProofFactories<'a, Tx> = (
HashedPostStateCursorFactory<DatabaseHashedCursorFactory<&'a Tx>, &'a HashedPostStateSorted>,
);
/// Creates a new proof task handle with a pre-initialized transaction pool.
///
/// This function creates a pool of database transactions that will be reused across
/// multiple proof tasks. Tasks are queued asynchronously and coordinated via notification,
/// with actual computation dispatched to Tokio's blocking threadpool using the pooled transactions.
/// Builds the worker-pool handle that queues proof tasks and reuses a fixed set of database transactions.
pub fn new_proof_task_handle<Factory>(
executor: Handle,
view: ConsistentDbView<Factory>,
@@ -64,14 +60,12 @@ pub fn new_proof_task_handle<Factory>(
where
Factory: DatabaseProviderFactory<Provider: BlockReader> + Clone + Send + Sync + 'static,
{
let max_concurrency = max_concurrency.max(1);
let storage_worker_count = storage_worker_count.max(1);
let queue_capacity = max_concurrency;
let worker_count = storage_worker_count.min(max_concurrency);
let queue_capacity = max_concurrency.max(1);
let worker_count = storage_worker_count.max(1).min(queue_capacity);
let (task_sender, task_receiver) = bounded(queue_capacity);
// Spawn dedicated blocking workers upfront. Each worker owns a single reusable transaction.
// Spawn blocking workers upfront; each owns a reusable transaction from the consistent view.
for worker_id in 0..worker_count {
let provider_ro = view.provider_ro()?;
let tx = provider_ro.into_tx();