Skip to content

Commit aa4a888

Browse files
committed
add pre-post execution duration metrics
1 parent a1d32b2 commit aa4a888

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ impl EngineApiMetrics {
7979
let mut executor = executor.with_state_hook(Some(Box::new(wrapper)));
8080

8181
let f = || {
82+
let start = Instant::now();
8283
debug_span!(target: "engine::tree", "pre execution")
8384
.entered()
8485
.in_scope(|| executor.apply_pre_execution_changes())?;
86+
self.executor.pre_execution_histogram.record(start.elapsed());
87+
8588
let exec_span = debug_span!(target: "engine::tree", "execution").entered();
8689
loop {
8790
let start = Instant::now();
@@ -103,10 +106,15 @@ impl EngineApiMetrics {
103106
enter.record("gas_used", gas_used);
104107
}
105108
drop(exec_span);
106-
debug_span!(target: "engine::tree", "finish")
109+
110+
let start = Instant::now();
111+
let result = debug_span!(target: "engine::tree", "finish")
107112
.entered()
108113
.in_scope(|| executor.finish())
109-
.map(|(evm, result)| (evm.into_db(), result))
114+
.map(|(evm, result)| (evm.into_db(), result));
115+
self.executor.post_execution_histogram.record(start.elapsed());
116+
117+
result
110118
};
111119

112120
// Use metered to execute and track timing/gas metrics

crates/evm/evm/src/metrics.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ 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 execute the pre-execution changes.
21+
pub pre_execution_histogram: Histogram,
2022
/// The Histogram for amount of time taken to wait for one transaction to be available.
2123
pub transaction_wait_histogram: Histogram,
2224
/// The Histogram for amount of time taken to execute one transaction.
2325
pub transaction_execution_histogram: Histogram,
24-
26+
/// The Histogram for amount of time taken to execute the post-execution changes.
27+
pub post_execution_histogram: Histogram,
2528
/// The Histogram for amount of time taken to execute blocks.
2629
pub execution_histogram: Histogram,
2730
/// The total amount of time it took to execute the latest block.

0 commit comments

Comments
 (0)