From 2f3d1121d5e1ea202d8b3d5ad4a6a0c4357b490b Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 4 Mar 2024 14:54:51 +0100 Subject: [PATCH 1/2] feat: more TPS metrics --- node/consensus/src/lib.rs | 17 +- node/metrics/snarkOS-grafana.json | 528 ++++++++++++++++++++++++++++-- node/metrics/src/names.rs | 12 +- 3 files changed, 527 insertions(+), 30 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index ea8d04d853..d590173f5b 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -212,6 +212,11 @@ impl Consensus { impl Consensus { /// Adds the given unconfirmed solution to the memory pool. pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { + #[cfg(feature = "metrics")] + { + metrics::increment_gauge(metrics::consensus::SOLUTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + } // Process the unconfirmed solution. { let solution_id = solution.commitment(); @@ -265,6 +270,11 @@ impl Consensus { /// Adds the given unconfirmed transaction to the memory pool. pub async fn add_unconfirmed_transaction(&self, transaction: Transaction) -> Result<()> { + #[cfg(feature = "metrics")] + { + metrics::increment_gauge(metrics::consensus::TRANSACTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + } // Process the unconfirmed transaction. { let transaction_id = transaction.id(); @@ -405,9 +415,14 @@ impl Consensus { let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64); let next_block_timestamp = next_block.header().metadata().timestamp(); let block_latency = next_block_timestamp - current_block_timestamp; + let num_sol = next_block.solutions().len(); + let num_tx = next_block.transactions().len(); + let num_transmissions = num_tx + num_sol; metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64); - metrics::increment_gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64); + metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64); + metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64); + metrics::increment_gauge(metrics::blocks::TRANSMISSIONS, num_transmissions as f64); metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64); metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64); metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64()); diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 25bd765970..03eeeacec4 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -564,10 +564,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -614,6 +610,198 @@ "title": "Total Transactions", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "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" + } + }, + "displayName": "Total Solutions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 41, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_solutions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Solutions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "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" + } + }, + "displayName": "Total Transmissions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 25 + }, + "id": 42, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_blocks_transmissions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transmissions", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -678,7 +866,7 @@ "h": 8, "w": 12, "x": 0, - "y": 25 + "y": 33 }, "id": 31, "options": { @@ -720,7 +908,7 @@ "h": 1, "w": 24, "x": 0, - "y": 33 + "y": 41 }, "id": 18, "panels": [], @@ -754,7 +942,7 @@ "h": 8, "w": 6, "x": 0, - "y": 34 + "y": 42 }, "id": 16, "options": { @@ -820,7 +1008,7 @@ "h": 8, "w": 6, "x": 6, - "y": 34 + "y": 42 }, "id": 25, "options": { @@ -882,7 +1070,7 @@ "h": 8, "w": 6, "x": 12, - "y": 34 + "y": 42 }, "id": 12, "options": { @@ -944,7 +1132,7 @@ "h": 8, "w": 6, "x": 18, - "y": 34 + "y": 42 }, "id": 24, "options": { @@ -996,10 +1184,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] } @@ -1010,7 +1194,7 @@ "h": 8, "w": 6, "x": 0, - "y": 42 + "y": 50 }, "id": 40, "options": { @@ -1056,7 +1240,7 @@ "h": 1, "w": 24, "x": 0, - "y": 50 + "y": 58 }, "id": 10, "panels": [], @@ -1128,7 +1312,7 @@ "h": 8, "w": 9, "x": 0, - "y": 51 + "y": 59 }, "id": 8, "options": { @@ -1252,7 +1436,7 @@ "h": 8, "w": 9, "x": 9, - "y": 51 + "y": 59 }, "id": 14, "options": { @@ -1289,6 +1473,294 @@ "title": "Commit Rounds Latency", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "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" + } + }, + "displayName": "Total Transactions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 67 + }, + "id": 43, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_transactions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transactions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "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" + } + }, + "displayName": "Total Solutions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 9, + "y": 67 + }, + "id": 44, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_solutions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Solutions", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "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" + } + }, + "displayName": "Total Transmissions", + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 9, + "x": 0, + "y": 75 + }, + "id": 45, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "snarkos_consensus_transmissions_total", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Total Transmissions", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -1351,9 +1823,9 @@ }, "gridPos": { "h": 8, - "w": 12, - "x": 6, - "y": 59 + "w": 9, + "x": 9, + "y": 75 }, "id": 38, "options": { @@ -1395,7 +1867,7 @@ "h": 1, "w": 24, "x": 0, - "y": 67 + "y": 83 }, "id": 4, "panels": [], @@ -1466,7 +1938,7 @@ "h": 8, "w": 12, "x": 6, - "y": 68 + "y": 84 }, "id": 37, "options": { @@ -1567,7 +2039,7 @@ "h": 8, "w": 12, "x": 0, - "y": 76 + "y": 92 }, "id": 32, "options": { @@ -1668,7 +2140,7 @@ "h": 8, "w": 12, "x": 12, - "y": 76 + "y": 92 }, "id": 33, "options": { @@ -1772,7 +2244,7 @@ "h": 8, "w": 12, "x": 0, - "y": 84 + "y": 100 }, "id": 34, "options": { @@ -1873,7 +2345,7 @@ "h": 8, "w": 12, "x": 12, - "y": 84 + "y": 100 }, "id": 35, "options": { @@ -1941,6 +2413,6 @@ "timezone": "", "title": "snarkOS", "uid": "ahTJm4-4k", - "version": 2, + "version": 1, "weekStart": "" } \ No newline at end of file diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index bcf163a533..47fa0573ff 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -14,16 +14,21 @@ pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED]; -pub(super) const GAUGE_NAMES: [&str; 13] = [ +pub(super) const GAUGE_NAMES: [&str; 18] = [ bft::CONNECTED, bft::CONNECTING, bft::LAST_STORED_ROUND, bft::PROPOSAL_ROUND, bft::CERTIFIED_BATCHES, blocks::HEIGHT, + blocks::SOLUTIONS, blocks::TRANSACTIONS, + blocks::TRANSMISSIONS, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, + consensus::SOLUTIONS, + consensus::TRANSACTIONS, + consensus::TRANSMISSIONS, router::CONNECTED, router::CANDIDATE, router::RESTRICTED, @@ -53,6 +58,8 @@ pub mod bft { pub mod blocks { pub const HEIGHT: &str = "snarkos_blocks_height_total"; pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total"; + pub const TRANSMISSIONS: &str = "snarkos_blocks_transmissions_total"; + pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total"; } pub mod consensus { @@ -60,6 +67,9 @@ pub mod consensus { pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_consensus_last_committed_round"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; + pub const TRANSACTIONS: &str = "snarkos_consensus_transactions_total"; + pub const TRANSMISSIONS: &str = "snarkos_consensus_transmissions_total"; + pub const SOLUTIONS: &str = "snarkos_consensus_solutions_total"; } pub mod router { From 8c3bfbafdfbf308bbdeb05892f3122294f5f4fdf Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 4 Mar 2024 15:20:44 +0100 Subject: [PATCH 2/2] fix: review comments --- node/consensus/src/lib.rs | 8 ++++---- node/metrics/snarkOS-grafana.json | 12 ++++++------ node/metrics/src/names.rs | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index d590173f5b..af0b568c01 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -214,8 +214,8 @@ impl Consensus { pub async fn add_unconfirmed_solution(&self, solution: ProverSolution) -> Result<()> { #[cfg(feature = "metrics")] { - metrics::increment_gauge(metrics::consensus::SOLUTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); } // Process the unconfirmed solution. { @@ -272,8 +272,8 @@ impl Consensus { pub async fn add_unconfirmed_transaction(&self, transaction: Transaction) -> Result<()> { #[cfg(feature = "metrics")] { - metrics::increment_gauge(metrics::consensus::TRANSACTIONS, 1f64); - metrics::increment_gauge(metrics::consensus::TRANSMISSIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64); + metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64); } // Process the unconfirmed transaction. { diff --git a/node/metrics/snarkOS-grafana.json b/node/metrics/snarkOS-grafana.json index 03eeeacec4..8e0a7cacfe 100644 --- a/node/metrics/snarkOS-grafana.json +++ b/node/metrics/snarkOS-grafana.json @@ -1556,7 +1556,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_transactions_total", + "expr": "snarkos_consensus_unconfirmed_transactions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1566,7 +1566,7 @@ "useBackend": false } ], - "title": "Total Transactions", + "title": "Total Unconfirmed Transactions", "type": "timeseries" }, { @@ -1652,7 +1652,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_solutions_total", + "expr": "snarkos_consensus_unconfirmed_solutions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1662,7 +1662,7 @@ "useBackend": false } ], - "title": "Total Solutions", + "title": "Total Unconfirmed Solutions", "type": "timeseries" }, { @@ -1748,7 +1748,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "snarkos_consensus_transmissions_total", + "expr": "snarkos_consensus_unconfirmed_transmissions_total", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1758,7 +1758,7 @@ "useBackend": false } ], - "title": "Total Transmissions", + "title": "Total Unconfirmed Transmissions", "type": "timeseries" }, { diff --git a/node/metrics/src/names.rs b/node/metrics/src/names.rs index 47fa0573ff..7afcc59845 100644 --- a/node/metrics/src/names.rs +++ b/node/metrics/src/names.rs @@ -26,9 +26,9 @@ pub(super) const GAUGE_NAMES: [&str; 18] = [ blocks::TRANSMISSIONS, consensus::COMMITTED_CERTIFICATES, consensus::LAST_COMMITTED_ROUND, - consensus::SOLUTIONS, - consensus::TRANSACTIONS, - consensus::TRANSMISSIONS, + consensus::UNCONFIRMED_SOLUTIONS, + consensus::UNCONFIRMED_TRANSACTIONS, + consensus::UNCONFIRMED_TRANSMISSIONS, router::CONNECTED, router::CANDIDATE, router::RESTRICTED, @@ -67,9 +67,9 @@ pub mod consensus { pub const COMMITTED_CERTIFICATES: &str = "snarkos_consensus_committed_certificates_total"; pub const LAST_COMMITTED_ROUND: &str = "snarkos_consensus_last_committed_round"; pub const BLOCK_LATENCY: &str = "snarkos_consensus_block_latency_secs"; - pub const TRANSACTIONS: &str = "snarkos_consensus_transactions_total"; - pub const TRANSMISSIONS: &str = "snarkos_consensus_transmissions_total"; - pub const SOLUTIONS: &str = "snarkos_consensus_solutions_total"; + pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_consensus_unconfirmed_transactions_total"; + pub const UNCONFIRMED_TRANSMISSIONS: &str = "snarkos_consensus_unconfirmed_transmissions_total"; + pub const UNCONFIRMED_SOLUTIONS: &str = "snarkos_consensus_unconfirmed_solutions_total"; } pub mod router {