From 105da6c85f004fb2b6819afbe25c5b94e1dde743 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Fri, 29 Nov 2024 13:07:42 +0000 Subject: [PATCH] Grafazos: Add file to generate profiling dashboard This dashboard contains information from prometheus scraping for store --- grafazos/Makefile | 4 ++- grafazos/src/octez-profiling.jsonnet | 32 +++++++++++++++++++ grafazos/src/profiling.jsonnet | 48 ++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 grafazos/src/octez-profiling.jsonnet create mode 100644 grafazos/src/profiling.jsonnet diff --git a/grafazos/Makefile b/grafazos/Makefile index 4b4b67309988..ced0bce17fb4 100644 --- a/grafazos/Makefile +++ b/grafazos/Makefile @@ -1,4 +1,4 @@ -all: basic logs full compact dal-basic +all: basic logs full compact dal-basic profiling NODE_INSTANCE_LABEL ?= instance STORAGE_MODE ?= default @@ -27,3 +27,5 @@ full: octez-full.jsonnet compact: octez-compact.jsonnet dal-basic: dal/dal-basic.jsonnet + +profiling: octez-profiling.jsonnet diff --git a/grafazos/src/octez-profiling.jsonnet b/grafazos/src/octez-profiling.jsonnet new file mode 100644 index 000000000000..62eef3690b3f --- /dev/null +++ b/grafazos/src/octez-profiling.jsonnet @@ -0,0 +1,32 @@ +// Copyright (c) 2024 TriliTech + +// Grafonnet +local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; +local dashboard = grafonnet.dashboard; +local panel = grafonnet.panel; + +// Base imports +local base = import './base.jsonnet'; +local profiling = import './profiling.jsonnet'; + +// Constants +local panelWidth = 10; +local panelHeight = 10; +local startY = 1; + +// Create the dashboard +dashboard.new('Octez Profiling Dashboard') ++ dashboard.withDescription('In-depth profiling for Octez function performance, showing average execution times.') ++ dashboard.withTags(['tezos', 'octez', 'profiling']) ++ dashboard.time.withFrom('now-8h') ++ dashboard.withRefresh('10s') ++ dashboard.withVariables([base.nodeInstance]) + ++ dashboard.withPanels( + [ + panel.row.new('Store Profiling'), + profiling.setHead(h=panelHeight, w=panelWidth, x=0, y=startY), + profiling.storeBlock(h=panelHeight, w=panelWidth, x=panelWidth, y=startY), + profiling.computeLiveBlocks(h=panelHeight, w=panelWidth, x=0, y=startY + panelHeight), + ] +) diff --git a/grafazos/src/profiling.jsonnet b/grafazos/src/profiling.jsonnet new file mode 100644 index 000000000000..343fdff06d6e --- /dev/null +++ b/grafazos/src/profiling.jsonnet @@ -0,0 +1,48 @@ +// Copyright (c) 2024 TriliTech + +// Grafonnet +local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; +local query = grafonnet.query; +local panel = grafonnet.panel; +local timeSeries = panel.timeSeries; + +// Base +local base = import './base.jsonnet'; +local graph = base.graph; + +// Constants +local rate = '30s'; +local msConversion = '1000'; // From seconds to milliseconds + +// Profiling constants +local store = 'profiling_store_time'; + +// Helper function to calculate rates for a profiling metric +local profilingRate(profiling, metricId, metricType) = + 'rate(' + profiling + '_' + metricType + '{id="' + metricId + '",' + base.node_instance + '="$node_instance"}[' + rate + '])'; + +// Helper function to create PromQL query for average execution time +local profilingQuery(profiling, metricId, legend) = + local sum = profilingRate(profiling, metricId, 'sum'); + local count = profilingRate(profiling, metricId, 'count'); + query.prometheus.new('Prometheus', '(' + sum + ' / ' + count + ') * ' + msConversion) + + query.prometheus.withLegendFormat(legend); + +// Helper function to create a Grafana panel +local profilingPanel(profiling, metricId, legend, color, h, w, x, y) = + local q = profilingQuery(profiling, metricId, legend); + graph.new('Average Execution Time: ' + metricId, [q], h, w, x, y) + + graph.withLegendBottom(calcs=['lastNotNull', 'mean', 'min', 'max']) + + graph.withFixedColor(color) + + timeSeries.standardOptions.withUnit('ms'); + +{ + setHead(h, w, x, y): + profilingPanel(store, 'set_head', 'Set Head', 'light-blue', h, w, x, y), + + storeBlock(h, w, x, y): + profilingPanel(store, 'store_block', 'Store Block', 'light-green', h, w, x, y), + + computeLiveBlocks(h, w, x, y): + profilingPanel(store, 'compute_live_blocks', 'Compute Live Blocks', 'light-red', h, w, x, y), +} -- GitLab