Skip to content

Commit a1d32b2

Browse files
committed
tx wait and execution metrics
1 parent 91013ab commit a1d32b2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

crates/engine/tree/src/tree/metrics.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl EngineApiMetrics {
6363
pub(crate) fn execute_metered<E, DB>(
6464
&self,
6565
executor: E,
66-
transactions: impl Iterator<Item = Result<impl ExecutableTx<E>, BlockExecutionError>>,
66+
mut transactions: impl Iterator<Item = Result<impl ExecutableTx<E>, BlockExecutionError>>,
6767
state_hook: Box<dyn OnStateHook>,
6868
) -> Result<(BlockExecutionOutput<E::Receipt>, Vec<Address>), BlockExecutionError>
6969
where
@@ -83,14 +83,21 @@ impl EngineApiMetrics {
8383
.entered()
8484
.in_scope(|| executor.apply_pre_execution_changes())?;
8585
let exec_span = debug_span!(target: "engine::tree", "execution").entered();
86-
for tx in transactions {
86+
loop {
87+
let start = Instant::now();
88+
let Some(tx) = transactions.next() else { break };
89+
self.executor.transaction_wait_histogram.record(start.elapsed());
90+
8791
let tx = tx?;
92+
senders.push(*tx.signer());
93+
8894
let span =
8995
debug_span!(target: "engine::tree", "execute tx", tx_hash=?tx.tx().tx_hash());
9096
let enter = span.entered();
9197
trace!(target: "engine::tree", "Executing transaction");
92-
senders.push(*tx.signer());
98+
let start = Instant::now();
9399
let gas_used = executor.execute_transaction(tx)?;
100+
self.executor.transaction_execution_histogram.record(start.elapsed());
94101

95102
// record the tx gas used
96103
enter.record("gas_used", gas_used);

crates/evm/evm/src/metrics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pub struct ExecutorMetrics {
1717
/// The Histogram for amount of gas used.
1818
pub gas_used_histogram: Histogram,
1919

20+
/// The Histogram for amount of time taken to wait for one transaction to be available.
21+
pub transaction_wait_histogram: Histogram,
22+
/// The Histogram for amount of time taken to execute one transaction.
23+
pub transaction_execution_histogram: Histogram,
24+
2025
/// The Histogram for amount of time taken to execute blocks.
2126
pub execution_histogram: Histogram,
2227
/// The total amount of time it took to execute the latest block.

0 commit comments

Comments
 (0)