perf: replace some std::time::Instant with quanta::Instant (#22211)

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
This commit is contained in:
Georgios Konstantopoulos
2026-02-15 21:15:06 -08:00
committed by GitHub
parent 7f5acc2723
commit 7594e1513a
38 changed files with 89 additions and 62 deletions

3
Cargo.lock generated
View File

@@ -7976,6 +7976,7 @@ dependencies = [
"page_size",
"parking_lot",
"proptest",
"quanta",
"reth-db-api",
"reth-fs-util",
"reth-libmdbx",
@@ -9601,6 +9602,7 @@ dependencies = [
"op-alloy-consensus",
"proptest",
"proptest-arbitrary-interop",
"quanta",
"rand 0.8.5",
"rand 0.9.2",
"rayon",
@@ -10355,6 +10357,7 @@ dependencies = [
"futures-util",
"metrics",
"pin-project",
"quanta",
"rayon",
"reth-metrics",
"thiserror 2.0.18",

View File

@@ -528,6 +528,7 @@ notify = { version = "8.0.0", default-features = false, features = ["macos_fseve
nybbles = { version = "0.4.8", default-features = false }
once_cell = { version = "1.19", default-features = false, features = ["critical-section"] }
parking_lot = "0.12"
quanta = "0.12"
paste = "1.0"
rand = "0.9"
rayon = "1.7"

View File

@@ -4,7 +4,7 @@ use crossbeam_channel::Sender as CrossbeamSender;
use reth_chain_state::ExecutedBlock;
use reth_errors::ProviderError;
use reth_ethereum_primitives::EthPrimitives;
use reth_primitives_traits::NodePrimitives;
use reth_primitives_traits::{FastInstant as Instant, NodePrimitives};
use reth_provider::{
providers::ProviderNodeTypes, BlockExecutionWriter, BlockHashReader, ChainStateBlockWriter,
DBProvider, DatabaseProviderFactory, ProviderFactory, SaveBlocksMode,
@@ -18,7 +18,6 @@ use std::{
Arc,
},
thread::JoinHandle,
time::Instant,
};
use thiserror::Error;
use tracing::{debug, error, instrument};

View File

@@ -3,7 +3,7 @@ use alloy_primitives::{Address, StorageKey, StorageValue, B256};
use metrics::{Gauge, Histogram};
use reth_errors::ProviderResult;
use reth_metrics::Metrics;
use reth_primitives_traits::{Account, Bytecode};
use reth_primitives_traits::{Account, Bytecode, FastInstant as Instant};
use reth_provider::{
AccountReader, BlockHashReader, BytecodeReader, HashedPostStateProvider, StateProofProvider,
StateProvider, StateRootProvider, StorageRootProvider,
@@ -14,7 +14,7 @@ use reth_trie::{
};
use std::{
sync::atomic::{AtomicU64, Ordering},
time::{Duration, Instant},
time::Duration,
};
/// Nanoseconds per second

View File

@@ -8,9 +8,9 @@ use reth_metrics::{
metrics::{Counter, Gauge, Histogram},
Metrics,
};
use reth_primitives_traits::constants::gas_units::MEGAGAS;
use reth_primitives_traits::{constants::gas_units::MEGAGAS, FastInstant as Instant};
use reth_trie::updates::TrieUpdates;
use std::time::{Duration, Instant};
use std::time::Duration;
/// Upper bounds for each gas bucket. The last bucket is a catch-all for
/// everything above the final threshold: <5M, 5-10M, 10-20M, 20-30M, 30-40M, >40M.

View File

@@ -27,7 +27,9 @@ use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{
BuiltPayload, EngineApiMessageVersion, NewPayloadError, PayloadBuilderAttributes, PayloadTypes,
};
use reth_primitives_traits::{NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader};
use reth_primitives_traits::{
FastInstant as Instant, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,
};
use reth_provider::{
BlockExecutionOutput, BlockExecutionResult, BlockReader, ChangeSetReader,
DatabaseProviderFactory, HashedPostStateProvider, ProviderError, StageCheckpointReader,
@@ -40,7 +42,7 @@ use reth_tasks::spawn_os_thread;
use reth_trie_db::ChangesetCache;
use revm::interpreter::debug_unreachable;
use state::TreeState;
use std::{fmt::Debug, ops, sync::Arc, time::Instant};
use std::{fmt::Debug, ops, sync::Arc};
use crossbeam_channel::{Receiver, Sender};
use tokio::sync::{

View File

@@ -27,7 +27,7 @@ use reth_evm::{
SpecFor, TxEnvFor,
};
use reth_metrics::Metrics;
use reth_primitives_traits::NodePrimitives;
use reth_primitives_traits::{FastInstant as Instant, NodePrimitives};
use reth_provider::{
BlockExecutionOutput, BlockReader, DatabaseProviderROFactory, StateProvider,
StateProviderFactory, StateReader,
@@ -49,7 +49,6 @@ use std::{
mpsc::{self, channel},
Arc,
},
time::Instant,
};
use tracing::{debug, debug_span, instrument, warn, Span};
@@ -611,7 +610,7 @@ where
let _enter =
debug_span!(target: "engine::tree::payload_processor", "preserve").entered();
let deferred = if let Some(state_root) = computed_state_root {
let start = std::time::Instant::now();
let start = Instant::now();
let (trie, deferred) = task.into_trie_for_reuse(
prune_depth,
max_storage_tries,

View File

@@ -8,6 +8,7 @@ use crossbeam_channel::{unbounded, Receiver as CrossbeamReceiver, Sender as Cros
use derive_more::derive::Deref;
use metrics::{Gauge, Histogram};
use reth_metrics::Metrics;
use reth_primitives_traits::FastInstant as Instant;
use reth_provider::AccountReader;
use reth_revm::state::EvmState;
use reth_trie::{
@@ -25,7 +26,7 @@ use reth_trie_parallel::{
targets_v2::MultiProofTargetsV2,
};
use revm_primitives::map::{hash_map, B256Map};
use std::{collections::BTreeMap, sync::Arc, time::Instant};
use std::{collections::BTreeMap, sync::Arc};
use tracing::{debug, error, instrument, trace};
/// Source of state changes, either from EVM execution or from a Block Access List.

View File

@@ -31,7 +31,7 @@ use metrics::{Counter, Gauge, Histogram};
use rayon::prelude::*;
use reth_evm::{execute::ExecutableTxFor, ConfigureEvm, Evm, EvmFor, RecoveredTx, SpecFor};
use reth_metrics::Metrics;
use reth_primitives_traits::NodePrimitives;
use reth_primitives_traits::{FastInstant as Instant, NodePrimitives};
use reth_provider::{
AccountReader, BlockExecutionOutput, BlockReader, StateProvider, StateProviderFactory,
StateReader,
@@ -39,13 +39,10 @@ use reth_provider::{
use reth_revm::{database::StateProviderDatabase, state::EvmState};
use reth_tasks::Runtime;
use reth_trie::MultiProofTargets;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{self, channel, Receiver, Sender, SyncSender},
Arc,
},
time::Instant,
use std::sync::{
atomic::{AtomicBool, Ordering},
mpsc::{self, channel, Receiver, Sender, SyncSender},
Arc,
};
use tracing::{debug, debug_span, instrument, trace, warn, Span};

View File

@@ -11,7 +11,7 @@ use alloy_primitives::B256;
use alloy_rlp::{Decodable, Encodable};
use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender};
use rayon::iter::ParallelIterator;
use reth_primitives_traits::{Account, ParallelBridgeBuffered};
use reth_primitives_traits::{Account, FastInstant as Instant, ParallelBridgeBuffered};
use reth_tasks::Runtime;
use reth_trie::{
proof_v2::Target, updates::TrieUpdates, DecodedMultiProofV2, HashedPostState, Nibbles,
@@ -32,10 +32,7 @@ use reth_trie_sparse::{
};
use revm_primitives::{hash_map::Entry, B256Map};
use smallvec::SmallVec;
use std::{
sync::mpsc,
time::{Duration, Instant},
};
use std::{sync::mpsc, time::Duration};
use tracing::{debug, debug_span, error, instrument, trace};
#[expect(clippy::large_enum_variant)]

View File

@@ -31,8 +31,8 @@ use reth_payload_primitives::{
BuiltPayload, InvalidPayloadAttributesError, NewPayloadError, PayloadTypes,
};
use reth_primitives_traits::{
AlloyBlockHeader, BlockBody, BlockTy, GotExpected, NodePrimitives, RecoveredBlock, SealedBlock,
SealedHeader, SignerRecoverable,
AlloyBlockHeader, BlockBody, BlockTy, FastInstant as Instant, GotExpected, NodePrimitives,
RecoveredBlock, SealedBlock, SealedHeader, SignerRecoverable,
};
use reth_provider::{
providers::OverlayStateProviderFactory, BlockExecutionOutput, BlockNumReader, BlockReader,
@@ -49,7 +49,6 @@ use std::{
collections::HashMap,
panic::{self, AssertUnwindSafe},
sync::{mpsc::RecvTimeoutError, Arc},
time::Instant,
};
use tracing::{debug, debug_span, error, info, instrument, trace, warn};

View File

@@ -23,7 +23,7 @@
use alloy_eips::BlockNumHash;
use alloy_primitives::B256;
use crossbeam_channel::Receiver as CrossbeamReceiver;
use std::time::Instant;
use reth_primitives_traits::FastInstant as Instant;
use tracing::trace;
/// The state of the persistence task.

View File

@@ -2,8 +2,7 @@
use alloy_consensus::BlockHeader;
use metrics::{Counter, Gauge, Histogram};
use reth_metrics::Metrics;
use reth_primitives_traits::{Block, RecoveredBlock};
use std::time::Instant;
use reth_primitives_traits::{Block, FastInstant as Instant, RecoveredBlock};
/// Executor metrics.
#[derive(Metrics, Clone)]

View File

@@ -39,6 +39,7 @@ bytes.workspace = true
dashmap = { workspace = true, features = ["inline"], optional = true }
derive_more.workspace = true
once_cell.workspace = true
quanta = { workspace = true, optional = true }
serde_with = { workspace = true, optional = true }
thiserror.workspace = true
@@ -85,6 +86,7 @@ std = [
"bytes/std",
"derive_more/std",
"once_cell/std",
"quanta",
"secp256k1?/std",
"thiserror/std",
"alloy-trie/std",

View File

@@ -117,6 +117,10 @@
#[macro_use]
extern crate alloc;
/// Re-export of [`quanta::Instant`] for high-resolution timing with minimal overhead.
#[cfg(feature = "std")]
pub use quanta::Instant as FastInstant;
/// Common constants.
pub mod constants;
pub use constants::gas_units::{format_gas, format_gas_throughput};

View File

@@ -6,6 +6,7 @@ use crate::{
};
use alloy_primitives::BlockNumber;
use reth_exex_types::FinishedExExHeight;
use reth_primitives_traits::FastInstant as Instant;
use reth_provider::{
DBProvider, DatabaseProviderFactory, PruneCheckpointReader, PruneCheckpointWriter,
StageCheckpointReader,
@@ -13,7 +14,7 @@ use reth_provider::{
use reth_prune_types::{PruneProgress, PrunedSegmentInfo, PrunerOutput};
use reth_stages_types::StageId;
use reth_tokio_util::{EventSender, EventStream};
use std::time::{Duration, Instant};
use std::time::Duration;
use tokio::sync::watch;
use tracing::{debug, instrument};

View File

@@ -9,7 +9,9 @@ use reth_db_api::{
transaction::{DbTx, DbTxMut},
RawValue,
};
use reth_primitives_traits::{GotExpected, NodePrimitives, SignedTransaction};
use reth_primitives_traits::{
FastInstant as Instant, GotExpected, NodePrimitives, SignedTransaction,
};
use reth_provider::{
BlockReader, DBProvider, EitherWriter, HeaderProvider, ProviderError, PruneCheckpointReader,
PruneCheckpointWriter, StaticFileProviderFactory, StatsReader, StorageSettingsCache,
@@ -21,7 +23,7 @@ use reth_stages_api::{
StageId, UnwindInput, UnwindOutput,
};
use reth_static_file_types::StaticFileSegment;
use std::{fmt::Debug, ops::Range, sync::mpsc, time::Instant};
use std::{fmt::Debug, ops::Range, sync::mpsc};
use thiserror::Error;
use tracing::*;

View File

@@ -6,7 +6,7 @@ use parking_lot::Mutex;
use rayon::prelude::*;
use reth_codecs::Compact;
use reth_db_api::table::Value;
use reth_primitives_traits::NodePrimitives;
use reth_primitives_traits::{FastInstant as Instant, NodePrimitives};
use reth_provider::{
providers::StaticFileWriter, BlockReader, ChainStateBlockReader, DBProvider,
DatabaseProviderFactory, StageCheckpointReader, StaticFileProviderFactory,
@@ -19,7 +19,6 @@ use reth_tokio_util::{EventSender, EventStream};
use std::{
ops::{Deref, RangeInclusive},
sync::Arc,
time::Instant,
};
use tracing::{debug, trace};

View File

@@ -31,6 +31,7 @@ eyre = { workspace = true, optional = true }
# metrics
reth-metrics = { workspace = true, optional = true }
metrics = { workspace = true, optional = true }
quanta = { workspace = true, optional = true }
# misc
page_size = { workspace = true, optional = true }
@@ -70,6 +71,7 @@ mdbx = [
"dep:reth-libmdbx",
"dep:eyre",
"dep:page_size",
"dep:quanta",
"reth-metrics",
"dep:metrics",
"dep:strum",

View File

@@ -1,8 +1,9 @@
use crate::Tables;
use metrics::Histogram;
use quanta::Instant;
use reth_metrics::{metrics::Counter, Metrics};
use rustc_hash::FxHashMap;
use std::time::{Duration, Instant};
use std::time::Duration;
use strum::{EnumCount, EnumIter, IntoEnumIterator};
const LARGE_VALUE_THRESHOLD_BYTES: usize = 4096;

View File

@@ -1,6 +1,7 @@
use metrics::{Gauge, Histogram};
use reth_metrics::Metrics;
use std::time::{Duration, Instant};
use reth_primitives_traits::FastInstant as Instant;
use std::time::Duration;
#[derive(Debug)]
pub(crate) struct DurationsRecorder<'a> {

View File

@@ -51,8 +51,8 @@ use reth_db_api::{
use reth_execution_types::{BlockExecutionOutput, BlockExecutionResult, Chain, ExecutionOutcome};
use reth_node_types::{BlockTy, BodyTy, HeaderTy, NodeTypes, ReceiptTy, TxTy};
use reth_primitives_traits::{
Account, Block as _, BlockBody as _, Bytecode, RecoveredBlock, SealedHeader, StorageEntry,
StorageSlotKey,
Account, Block as _, BlockBody as _, Bytecode, FastInstant as Instant, RecoveredBlock,
SealedHeader, StorageEntry, StorageSlotKey,
};
use reth_prune_types::{
PruneCheckpoint, PruneMode, PruneModes, PruneSegment, MINIMUM_UNWIND_SAFE_DISTANCE,
@@ -79,7 +79,6 @@ use std::{
fmt::Debug,
ops::{Deref, DerefMut, Range, RangeBounds, RangeInclusive},
sync::Arc,
time::Instant,
};
use tracing::{debug, instrument, trace};

View File

@@ -19,7 +19,7 @@ use reth_db_api::{
table::{Compress, Decode, Decompress, Encode, Table},
tables, BlockNumberList, DatabaseError,
};
use reth_primitives_traits::BlockBody as _;
use reth_primitives_traits::{BlockBody as _, FastInstant as Instant};
use reth_prune_types::PruneMode;
use reth_storage_errors::{
db::{DatabaseErrorInfo, DatabaseWriteError, DatabaseWriteOperation, LogLevel},
@@ -36,7 +36,6 @@ use std::{
fmt,
path::{Path, PathBuf},
sync::Arc,
time::Instant,
};
use tracing::instrument;

View File

@@ -10,6 +10,7 @@ use reth_db::models::{AccountBeforeTx, StorageBeforeTx};
use reth_db_api::models::CompactU256;
use reth_nippy_jar::{NippyJar, NippyJarError, NippyJarWriter};
use reth_node_types::NodePrimitives;
use reth_primitives_traits::FastInstant as Instant;
use reth_static_file_types::{
ChangesetOffset, ChangesetOffsetReader, ChangesetOffsetWriter, SegmentHeader,
SegmentRangeInclusive, StaticFileSegment,
@@ -21,7 +22,6 @@ use std::{
fmt::Debug,
path::{Path, PathBuf},
sync::{Arc, Weak},
time::Instant,
};
use tracing::{debug, instrument};

View File

@@ -23,6 +23,7 @@ metrics.workspace = true
# misc
auto_impl.workspace = true
quanta.workspace = true
tracing.workspace = true
thiserror.workspace = true
dyn-clone.workspace = true

View File

@@ -25,7 +25,7 @@ use std::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,
},
time::Duration,
time::{Duration, Instant},
};
use tokio::{runtime::Handle, sync::mpsc::UnboundedSender, task::JoinHandle};
use tracing::{debug, error};
@@ -277,6 +277,10 @@ struct RuntimeInner {
/// The task monitors critical tasks for panics and fires the shutdown signal.
/// Can be taken via [`Runtime::take_task_manager_handle`] to poll for panic errors.
task_manager_handle: Mutex<Option<JoinHandle<Result<(), PanickedTaskError>>>>,
/// Handle to the quanta upkeep thread that periodically refreshes the cached
/// high-resolution timestamp used by [`quanta::Instant::recent()`].
/// Dropped when the runtime is dropped, stopping the upkeep thread.
_quanta_upkeep: Option<quanta::Handle>,
}
// ── Runtime ───────────────────────────────────────────────────────────
@@ -720,9 +724,9 @@ impl Runtime {
fn do_graceful_shutdown(&self, timeout: Option<Duration>) -> bool {
let _ = self.0.task_events_tx.send(TaskEvent::GracefulShutdown);
let deadline = timeout.map(|t| std::time::Instant::now() + t);
let deadline = timeout.map(|t| Instant::now() + t);
while self.0.graceful_tasks.load(Ordering::SeqCst) > 0 {
if deadline.is_some_and(|d| std::time::Instant::now() > d) {
if deadline.is_some_and(|d| Instant::now() > d) {
debug!("graceful shutdown timed out");
return false;
}
@@ -919,6 +923,8 @@ impl RuntimeBuilder {
result
});
let quanta_upkeep = quanta::Upkeep::new(Duration::from_millis(1)).start().ok();
let inner = RuntimeInner {
_tokio_runtime: owned_runtime,
handle,
@@ -941,6 +947,7 @@ impl RuntimeBuilder {
#[cfg(feature = "rayon")]
prewarming_pool,
task_manager_handle: Mutex::new(Some(task_manager_handle)),
_quanta_upkeep: quanta_upkeep,
};
Ok(Runtime(Arc::new(inner)))

View File

@@ -13,7 +13,7 @@ workspace = true
[dependencies]
# reth
reth-primitives-traits.workspace = true
reth-primitives-traits = { workspace = true, features = ["std"] }
reth-execution-errors.workspace = true
reth-db-api.workspace = true
reth-trie.workspace = true

View File

@@ -10,6 +10,7 @@
use crate::{DatabaseStateRoot, DatabaseTrieCursorFactory};
use alloy_primitives::{map::B256Map, BlockNumber, B256};
use parking_lot::RwLock;
use reth_primitives_traits::FastInstant as Instant;
use reth_storage_api::{
BlockNumReader, ChangeSetReader, DBProvider, StageCheckpointReader, StorageChangeSetReader,
StorageSettingsCache,
@@ -21,7 +22,7 @@ use reth_trie::{
StateRoot, TrieInputSorted,
};
use reth_trie_common::updates::{StorageTrieUpdatesSorted, TrieUpdatesSorted};
use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc, time::Instant};
use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc};
use tracing::debug;
#[cfg(feature = "metrics")]

View File

@@ -13,7 +13,7 @@ workspace = true
[dependencies]
# reth
reth-primitives-traits = { workspace = true, features = ["dashmap"] }
reth-primitives-traits = { workspace = true, features = ["dashmap", "std"] }
reth-execution-errors.workspace = true
reth-provider.workspace = true
reth-storage-errors.workspace = true

View File

@@ -10,13 +10,14 @@ use crate::{
use alloy_primitives::{map::B256Set, B256};
use crossbeam_channel::{unbounded as crossbeam_unbounded, Receiver as CrossbeamReceiver};
use reth_execution_errors::StorageRootError;
use reth_primitives_traits::FastInstant as Instant;
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
prefix_set::{PrefixSet, PrefixSetMut, TriePrefixSets, TriePrefixSetsMut},
DecodedMultiProof, DecodedStorageMultiProof, HashedPostState, MultiProofTargets, Nibbles,
};
use reth_trie_common::added_removed_keys::MultiAddedRemovedKeys;
use std::{sync::Arc, time::Instant};
use std::sync::Arc;
use tracing::trace;
/// Parallel proof calculator.

View File

@@ -43,7 +43,10 @@ use alloy_primitives::{
use alloy_rlp::{BufMut, Encodable};
use crossbeam_channel::{unbounded, Receiver as CrossbeamReceiver, Sender as CrossbeamSender};
use reth_execution_errors::{SparseTrieError, SparseTrieErrorKind, StateProofError};
use reth_primitives_traits::dashmap::{self, DashMap};
use reth_primitives_traits::{
dashmap::{self, DashMap},
FastInstant as Instant,
};
use reth_provider::{DatabaseProviderROFactory, ProviderError, ProviderResult};
use reth_storage_errors::db::DatabaseError;
use reth_tasks::Runtime;
@@ -73,7 +76,7 @@ use std::{
mpsc::{channel, Receiver, Sender},
Arc,
},
time::{Duration, Instant},
time::Duration,
};
use tracing::{debug, debug_span, error, instrument, trace};

View File

@@ -13,6 +13,8 @@ use alloy_rlp::Decodable;
use alloy_trie::{BranchNodeCompact, TrieMask, EMPTY_ROOT_HASH};
use core::cmp::{Ord, Ordering, PartialOrd};
use reth_execution_errors::{SparseTrieError, SparseTrieErrorKind, SparseTrieResult};
#[cfg(feature = "metrics")]
use reth_primitives_traits::FastInstant as Instant;
use reth_trie_common::{
prefix_set::{PrefixSet, PrefixSetMut},
BranchNodeMasks, BranchNodeMasksMap, BranchNodeRef, ExtensionNodeRef, LeafNodeRef, Nibbles,
@@ -966,7 +968,7 @@ impl SparseTrie for ParallelSparseTrie {
changed_subtries.par_iter_mut().for_each(|changed_subtrie| {
#[cfg(feature = "metrics")]
let start = std::time::Instant::now();
let start = Instant::now();
changed_subtrie.subtrie.update_hashes(
&mut changed_subtrie.prefix_set,
&mut changed_subtrie.update_actions_buf,
@@ -1976,7 +1978,7 @@ impl ParallelSparseTrie {
});
#[cfg(feature = "metrics")]
let start = std::time::Instant::now();
let start = Instant::now();
let mut update_actions_buf =
self.updates_enabled().then(|| self.update_actions_buffers.pop().unwrap_or_default());

View File

@@ -12,6 +12,8 @@ use alloy_rlp::{Decodable, Encodable};
use alloy_trie::proof::DecodedProofNodes;
use reth_execution_errors::{SparseStateTrieErrorKind, SparseStateTrieResult, SparseTrieErrorKind};
use reth_primitives_traits::Account;
#[cfg(feature = "std")]
use reth_primitives_traits::FastInstant as Instant;
use reth_trie_common::{
proof::ProofNodes,
updates::{StorageTrieUpdates, TrieUpdates},
@@ -1191,7 +1193,7 @@ impl<S: SparseTrieTrait> StorageTries<S> {
/// Keeps the top `max_storage_tries` by a score combining size and heat.
/// Evicts lower-scored tries entirely, prunes kept tries to `max_depth`.
fn prune(&mut self, max_depth: usize, max_storage_tries: usize) {
let fn_start = std::time::Instant::now();
let fn_start = Instant::now();
let mut stats =
StorageTriesPruneStats { total_tries_before: self.tries.len(), ..Default::default() };
@@ -1248,7 +1250,7 @@ impl<S: SparseTrieTrait> StorageTries<S> {
// - They haven't been pruned since last access
// - They're large enough to be worth pruning
const MIN_SIZE_TO_PRUNE: usize = 1000;
let prune_start = std::time::Instant::now();
let prune_start = Instant::now();
for (address, size) in &tries_to_keep {
if *size < MIN_SIZE_TO_PRUNE {
stats.skipped_small += 1;

View File

@@ -14,7 +14,7 @@ workspace = true
[dependencies]
# reth
reth-execution-errors.workspace = true
reth-primitives-traits.workspace = true
reth-primitives-traits = { workspace = true, features = ["std"] }
reth-stages-types.workspace = true
reth-storage-errors.workspace = true
reth-trie-sparse.workspace = true

View File

@@ -1,7 +1,8 @@
use super::{HashedCursor, HashedStorageCursor};
use alloy_primitives::B256;
use reth_primitives_traits::FastInstant as Instant;
use reth_storage_errors::db::DatabaseError;
use std::time::{Duration, Instant};
use std::time::Duration;
use tracing::trace_span;
#[cfg(feature = "metrics")]

View File

@@ -2,11 +2,11 @@ use super::{Proof, StorageProof};
use crate::{hashed_cursor::HashedCursorFactory, trie_cursor::TrieCursorFactory};
use alloy_primitives::{map::HashSet, B256};
use reth_execution_errors::{SparseTrieError, SparseTrieErrorKind};
use reth_primitives_traits::FastInstant as Instant;
use reth_trie_common::{MultiProofTargets, Nibbles};
use reth_trie_sparse::provider::{
pad_path_to_key, RevealedNode, TrieNodeProvider, TrieNodeProviderFactory,
};
use std::time::Instant;
use tracing::{enabled, trace, Level};
/// Factory for instantiating providers capable of retrieving blinded trie nodes via proofs.

View File

@@ -1,4 +1,5 @@
use std::time::{Duration, Instant};
use reth_primitives_traits::FastInstant as Instant;
use std::time::Duration;
/// Trie stats.
#[derive(Clone, Copy, Debug)]

View File

@@ -1,8 +1,9 @@
use super::{TrieCursor, TrieStorageCursor};
use crate::{BranchNodeCompact, Nibbles};
use alloy_primitives::B256;
use reth_primitives_traits::FastInstant as Instant;
use reth_storage_errors::db::DatabaseError;
use std::time::{Duration, Instant};
use std::time::Duration;
use tracing::trace_span;
#[cfg(feature = "metrics")]