mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: replace broken canonicalization metrics (#8500)
This commit is contained in:
@ -38,11 +38,17 @@ pub(crate) struct MakeCanonicalDurationsRecorder {
|
|||||||
start: Instant,
|
start: Instant,
|
||||||
pub(crate) actions: Vec<(MakeCanonicalAction, Duration)>,
|
pub(crate) actions: Vec<(MakeCanonicalAction, Duration)>,
|
||||||
latest: Option<Duration>,
|
latest: Option<Duration>,
|
||||||
|
current_metrics: MakeCanonicalMetrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MakeCanonicalDurationsRecorder {
|
impl Default for MakeCanonicalDurationsRecorder {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { start: Instant::now(), actions: Vec::new(), latest: None }
|
Self {
|
||||||
|
start: Instant::now(),
|
||||||
|
actions: Vec::new(),
|
||||||
|
latest: None,
|
||||||
|
current_metrics: MakeCanonicalMetrics::default(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +60,7 @@ impl MakeCanonicalDurationsRecorder {
|
|||||||
let duration = elapsed - self.latest.unwrap_or_default();
|
let duration = elapsed - self.latest.unwrap_or_default();
|
||||||
|
|
||||||
self.actions.push((action, duration));
|
self.actions.push((action, duration));
|
||||||
MakeCanonicalMetrics::new_with_labels(&[("action", action.as_str())])
|
self.current_metrics.record(action, duration);
|
||||||
.duration
|
|
||||||
.record(duration);
|
|
||||||
|
|
||||||
self.latest = Some(elapsed);
|
self.latest = Some(elapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,30 +92,61 @@ pub(crate) enum MakeCanonicalAction {
|
|||||||
ClearTrieUpdatesForOtherChilds,
|
ClearTrieUpdatesForOtherChilds,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MakeCanonicalAction {
|
/// Canonicalization metrics
|
||||||
const fn as_str(&self) -> &'static str {
|
#[derive(Metrics)]
|
||||||
match self {
|
#[metrics(scope = "blockchain_tree.make_canonical")]
|
||||||
Self::CloneOldBlocks => "clone old blocks",
|
struct MakeCanonicalMetrics {
|
||||||
Self::FindCanonicalHeader => "find canonical header",
|
/// Duration of the clone old blocks action.
|
||||||
Self::SplitChain => "split chain",
|
clone_old_blocks: Histogram,
|
||||||
Self::SplitChainForks => "split chain forks",
|
/// Duration of the find canonical header action.
|
||||||
Self::MergeAllChains => "merge all chains",
|
find_canonical_header: Histogram,
|
||||||
Self::UpdateCanonicalIndex => "update canonical index",
|
/// Duration of the split chain action.
|
||||||
Self::RetrieveStateTrieUpdates => "retrieve state trie updates",
|
split_chain: Histogram,
|
||||||
Self::CommitCanonicalChainToDatabase => "commit canonical chain to database",
|
/// Duration of the split chain forks action.
|
||||||
Self::RevertCanonicalChainFromDatabase => "revert canonical chain from database",
|
split_chain_forks: Histogram,
|
||||||
Self::InsertOldCanonicalChain => "insert old canonical chain",
|
/// Duration of the merge all chains action.
|
||||||
Self::ClearTrieUpdatesForOtherChilds => {
|
merge_all_chains: Histogram,
|
||||||
"clear trie updates of other childs chains after fork choice update"
|
/// Duration of the update canonical index action.
|
||||||
|
update_canonical_index: Histogram,
|
||||||
|
/// Duration of the retrieve state trie updates action.
|
||||||
|
retrieve_state_trie_updates: Histogram,
|
||||||
|
/// Duration of the commit canonical chain to database action.
|
||||||
|
commit_canonical_chain_to_database: Histogram,
|
||||||
|
/// Duration of the revert canonical chain from database action.
|
||||||
|
revert_canonical_chain_from_database: Histogram,
|
||||||
|
/// Duration of the insert old canonical chain action.
|
||||||
|
insert_old_canonical_chain: Histogram,
|
||||||
|
/// Duration of the clear trie updates of other childs chains after fork choice update action.
|
||||||
|
clear_trie_updates_for_other_childs: Histogram,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MakeCanonicalMetrics {
|
||||||
|
/// Records the duration for the given action.
|
||||||
|
pub(crate) fn record(&self, action: MakeCanonicalAction, duration: Duration) {
|
||||||
|
match action {
|
||||||
|
MakeCanonicalAction::CloneOldBlocks => self.clone_old_blocks.record(duration),
|
||||||
|
MakeCanonicalAction::FindCanonicalHeader => self.find_canonical_header.record(duration),
|
||||||
|
MakeCanonicalAction::SplitChain => self.split_chain.record(duration),
|
||||||
|
MakeCanonicalAction::SplitChainForks => self.split_chain_forks.record(duration),
|
||||||
|
MakeCanonicalAction::MergeAllChains => self.merge_all_chains.record(duration),
|
||||||
|
MakeCanonicalAction::UpdateCanonicalIndex => {
|
||||||
|
self.update_canonical_index.record(duration)
|
||||||
|
}
|
||||||
|
MakeCanonicalAction::RetrieveStateTrieUpdates => {
|
||||||
|
self.retrieve_state_trie_updates.record(duration)
|
||||||
|
}
|
||||||
|
MakeCanonicalAction::CommitCanonicalChainToDatabase => {
|
||||||
|
self.commit_canonical_chain_to_database.record(duration)
|
||||||
|
}
|
||||||
|
MakeCanonicalAction::RevertCanonicalChainFromDatabase => {
|
||||||
|
self.revert_canonical_chain_from_database.record(duration)
|
||||||
|
}
|
||||||
|
MakeCanonicalAction::InsertOldCanonicalChain => {
|
||||||
|
self.insert_old_canonical_chain.record(duration)
|
||||||
|
}
|
||||||
|
MakeCanonicalAction::ClearTrieUpdatesForOtherChilds => {
|
||||||
|
self.clear_trie_updates_for_other_childs.record(duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Metrics)]
|
|
||||||
#[metrics(scope = "blockchain_tree.make_canonical")]
|
|
||||||
/// Canonicalization metrics
|
|
||||||
struct MakeCanonicalMetrics {
|
|
||||||
/// The time it took to execute an action
|
|
||||||
duration: Histogram,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4471,131 +4471,6 @@
|
|||||||
"title": "Canonical Commit Latency time",
|
"title": "Canonical Commit Latency time",
|
||||||
"type": "timeseries"
|
"type": "timeseries"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"description": "",
|
|
||||||
"fieldConfig": {
|
|
||||||
"defaults": {
|
|
||||||
"color": {
|
|
||||||
"mode": "palette-classic"
|
|
||||||
},
|
|
||||||
"custom": {
|
|
||||||
"axisBorderShow": false,
|
|
||||||
"axisCenteredZero": false,
|
|
||||||
"axisColorMode": "text",
|
|
||||||
"axisLabel": "",
|
|
||||||
"axisPlacement": "auto",
|
|
||||||
"barAlignment": 0,
|
|
||||||
"drawStyle": "line",
|
|
||||||
"fillOpacity": 0,
|
|
||||||
"gradientMode": "none",
|
|
||||||
"hideFrom": {
|
|
||||||
"legend": false,
|
|
||||||
"tooltip": false,
|
|
||||||
"viz": false
|
|
||||||
},
|
|
||||||
"insertNulls": false,
|
|
||||||
"lineInterpolation": "linear",
|
|
||||||
"lineWidth": 1,
|
|
||||||
"pointSize": 5,
|
|
||||||
"scaleDistribution": {
|
|
||||||
"type": "linear"
|
|
||||||
},
|
|
||||||
"showPoints": "auto",
|
|
||||||
"spanNulls": false,
|
|
||||||
"stacking": {
|
|
||||||
"group": "A",
|
|
||||||
"mode": "none"
|
|
||||||
},
|
|
||||||
"thresholdsStyle": {
|
|
||||||
"mode": "off"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mappings": [],
|
|
||||||
"thresholds": {
|
|
||||||
"mode": "absolute",
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"color": "green",
|
|
||||||
"value": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"color": "red",
|
|
||||||
"value": 80
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "s",
|
|
||||||
"unitScale": true
|
|
||||||
},
|
|
||||||
"overrides": []
|
|
||||||
},
|
|
||||||
"gridPos": {
|
|
||||||
"h": 8,
|
|
||||||
"w": 12,
|
|
||||||
"x": 0,
|
|
||||||
"y": 154
|
|
||||||
},
|
|
||||||
"id": 158,
|
|
||||||
"options": {
|
|
||||||
"legend": {
|
|
||||||
"calcs": [],
|
|
||||||
"displayMode": "list",
|
|
||||||
"placement": "bottom",
|
|
||||||
"showLegend": true
|
|
||||||
},
|
|
||||||
"tooltip": {
|
|
||||||
"mode": "single",
|
|
||||||
"sort": "none"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"editorMode": "code",
|
|
||||||
"expr": "reth_blockchain_tree_make_canonical_duration{instance=~\"$instance\", action=~\"$blockchain_tree_action\", quantile=\"0.5\"} ",
|
|
||||||
"instant": false,
|
|
||||||
"legendFormat": "${blockchain_tree_action} {{quantile}} percentile",
|
|
||||||
"range": true,
|
|
||||||
"refId": "A"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"editorMode": "code",
|
|
||||||
"expr": "reth_blockchain_tree_make_canonical_duration{instance=~\"$instance\", action=~\"$blockchain_tree_action\", quantile=\"0.95\"} ",
|
|
||||||
"hide": false,
|
|
||||||
"instant": false,
|
|
||||||
"legendFormat": "${blockchain_tree_action} {{quantile}} percentile",
|
|
||||||
"range": true,
|
|
||||||
"refId": "B"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"editorMode": "code",
|
|
||||||
"exemplar": false,
|
|
||||||
"expr": "reth_blockchain_tree_make_canonical_duration{instance=~\"$instance\", action=~\"$blockchain_tree_action\", quantile=\"1\"} ",
|
|
||||||
"hide": false,
|
|
||||||
"instant": false,
|
|
||||||
"legendFormat": "${blockchain_tree_action} {{quantile}} percentile",
|
|
||||||
"range": true,
|
|
||||||
"refId": "C"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"title": "Canonicalization duration per action",
|
|
||||||
"type": "timeseries"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"datasource": {
|
"datasource": {
|
||||||
"type": "prometheus",
|
"type": "prometheus",
|
||||||
@ -8456,52 +8331,6 @@
|
|||||||
"skipUrlSync": false,
|
"skipUrlSync": false,
|
||||||
"sort": 0,
|
"sort": 0,
|
||||||
"type": "query"
|
"type": "query"
|
||||||
},
|
|
||||||
{
|
|
||||||
"current": {},
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"definition": "label_values(reth_blockchain_tree_make_canonical_duration{instance=\"$instance\"},action)",
|
|
||||||
"hide": 0,
|
|
||||||
"includeAll": false,
|
|
||||||
"label": "Blockchain Tree Canonicalization Action",
|
|
||||||
"multi": false,
|
|
||||||
"name": "blockchain_tree_action",
|
|
||||||
"options": [],
|
|
||||||
"query": {
|
|
||||||
"query": "label_values(reth_blockchain_tree_make_canonical_duration{instance=\"$instance\"},action)",
|
|
||||||
"refId": "PrometheusVariableQueryEditor-VariableQuery"
|
|
||||||
},
|
|
||||||
"refresh": 1,
|
|
||||||
"regex": "",
|
|
||||||
"skipUrlSync": false,
|
|
||||||
"sort": 0,
|
|
||||||
"type": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"current": {},
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "${DS_PROMETHEUS}"
|
|
||||||
},
|
|
||||||
"definition": "label_values(reth_storage_providers_database_duration{instance=\"$instance\"},action)",
|
|
||||||
"hide": 0,
|
|
||||||
"includeAll": false,
|
|
||||||
"label": "Database Storage Providers Action",
|
|
||||||
"multi": false,
|
|
||||||
"name": "database_action",
|
|
||||||
"options": [],
|
|
||||||
"query": {
|
|
||||||
"query": "label_values(reth_storage_providers_database_duration{instance=\"$instance\"},action)",
|
|
||||||
"refId": "PrometheusVariableQueryEditor-DatabaseQuery"
|
|
||||||
},
|
|
||||||
"refresh": 1,
|
|
||||||
"regex": "",
|
|
||||||
"skipUrlSync": false,
|
|
||||||
"sort": 0,
|
|
||||||
"type": "query"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -8515,4 +8344,4 @@
|
|||||||
"uid": "2k8BXz24x",
|
"uid": "2k8BXz24x",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"weekStart": ""
|
"weekStart": ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user