perf(tree): add metric for payload conversion + validation latency (#17499)

This commit is contained in:
Dan Cline
2025-07-19 02:44:39 -04:00
committed by GitHub
parent b0aed0dded
commit f0572fc9d3
2 changed files with 17 additions and 0 deletions

View File

@@ -71,6 +71,10 @@ pub(crate) struct BlockValidationMetrics {
pub(crate) state_root_duration: Gauge,
/// Trie input computation duration
pub(crate) trie_input_duration: Histogram,
/// Payload conversion and validation latency
pub(crate) payload_validation_duration: Gauge,
/// Histogram of payload validation latency
pub(crate) payload_validation_histogram: Histogram,
}
impl BlockValidationMetrics {
@@ -81,6 +85,13 @@ impl BlockValidationMetrics {
self.state_root_duration.set(elapsed_as_secs);
self.state_root_histogram.record(elapsed_as_secs);
}
/// Records a new payload validation time, updating both the histogram and the payload
/// validation gauge
pub(crate) fn record_payload_validation(&self, elapsed_as_secs: f64) {
self.payload_validation_duration.set(elapsed_as_secs);
self.payload_validation_histogram.record(elapsed_as_secs);
}
}
/// Metrics for the blockchain tree block buffer

View File

@@ -526,6 +526,8 @@ where
trace!(target: "engine::tree", "invoked new payload");
self.metrics.engine.new_payload_messages.increment(1);
let validation_start = Instant::now();
// Ensures that the given payload does not violate any consensus rules that concern the
// block's layout, like:
// - missing or invalid base fee
@@ -573,6 +575,10 @@ where
}
};
self.metrics
.block_validation
.record_payload_validation(validation_start.elapsed().as_secs_f64());
let num_hash = block.num_hash();
let engine_event = BeaconConsensusEngineEvent::BlockReceived(num_hash);
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));