mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(trie): use global thread pool in async state root calculation (#11057)
This commit is contained in:
@ -3,13 +3,11 @@ use alloy_primitives::{B256, U256};
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner};
|
||||
use proptest_arbitrary_interop::arb;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use reth_primitives::Account;
|
||||
use reth_provider::{
|
||||
providers::ConsistentDbView, test_utils::create_test_provider_factory, StateChangeWriter,
|
||||
TrieWriter,
|
||||
};
|
||||
use reth_tasks::pool::BlockingTaskPool;
|
||||
use reth_trie::{
|
||||
hashed_cursor::HashedPostStateCursorFactory, HashedPostState, HashedStorage, StateRoot,
|
||||
TrieInput,
|
||||
@ -23,7 +21,6 @@ pub fn calculate_state_root(c: &mut Criterion) {
|
||||
group.sample_size(20);
|
||||
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
let blocking_pool = BlockingTaskPool::new(ThreadPoolBuilder::default().build().unwrap());
|
||||
|
||||
for size in [1_000, 3_000, 5_000, 10_000] {
|
||||
let (db_state, updated_state) = generate_test_data(size);
|
||||
@ -77,13 +74,7 @@ pub fn calculate_state_root(c: &mut Criterion) {
|
||||
// async root
|
||||
group.bench_function(BenchmarkId::new("async root", size), |b| {
|
||||
b.to_async(&runtime).iter_with_setup(
|
||||
|| {
|
||||
AsyncStateRoot::new(
|
||||
view.clone(),
|
||||
blocking_pool.clone(),
|
||||
TrieInput::from_state(updated_state.clone()),
|
||||
)
|
||||
},
|
||||
|| AsyncStateRoot::new(view.clone(), TrieInput::from_state(updated_state.clone())),
|
||||
|calculator| calculator.incremental_root(),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user