From 79d7c06644fecc5212060bcce7a95eb622db8d60 Mon Sep 17 00:00:00 2001 From: Miguel Angel Rojo Fernandez Date: Fri, 10 Jan 2025 12:42:47 +0000 Subject: [PATCH 1/3] first commit --- cmd/thor/node/metrics.go | 14 ++++++++------ cmd/thor/node/node.go | 9 ++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cmd/thor/node/metrics.go b/cmd/thor/node/metrics.go index a6d56f2dc..b7c2ec2c6 100644 --- a/cmd/thor/node/metrics.go +++ b/cmd/thor/node/metrics.go @@ -10,10 +10,12 @@ import ( ) var ( - metricBlockProcessedCount = metrics.LazyLoadCounterVec("block_processed_count", []string{"type", "success"}) - metricBlockProcessedTxs = metrics.LazyLoadGaugeVec("block_processed_tx_gauge", []string{"type"}) - metricBlockProcessedGas = metrics.LazyLoadGaugeVec("block_processed_gas_gauge", []string{"type"}) - metricBlockProcessedDuration = metrics.LazyLoadHistogram("block_processed_duration_ms", metrics.Bucket10s) - metricChainForkCount = metrics.LazyLoadCounter("chain_fork_count") - metricChainForkSize = metrics.LazyLoadGauge("chain_fork_gauge") + metricBlockProcessedCount = metrics.LazyLoadCounterVec("block_processed_count", []string{"type", "success"}) + metricBlockProcessedTxs = metrics.LazyLoadGaugeVec("block_processed_tx_gauge", []string{"type"}) + metricBlockProcessedGas = metrics.LazyLoadGaugeVec("block_processed_gas_gauge", []string{"type"}) + metricBlockProcessedDuration = metrics.LazyLoadHistogram("block_processed_duration_ms", metrics.Bucket10s) + metricChainForkCount = metrics.LazyLoadCounter("chain_fork_count") + metricChainForkSize = metrics.LazyLoadGauge("chain_fork_gauge") + metricBlockProcessingLockCount = metrics.LazyLoadCounterVec("block_processing_lock_count", []string{"type"}) + metricBlockProcessingLockDuration = metrics.LazyLoadHistogram("block_processing_lock_duration_ms", metrics.Bucket10s) ) diff --git a/cmd/thor/node/node.go b/cmd/thor/node/node.go index 251e421b0..2b0eb36b3 100644 --- a/cmd/thor/node/node.go +++ b/cmd/thor/node/node.go @@ -274,8 +274,15 @@ func (n *Node) txStashLoop(ctx context.Context) { // guardBlockProcessing adds lock on block processing and maintains block conflicts. func (n *Node) guardBlockProcessing(blockNum uint32, process func(conflicts uint32) error) error { + startTime := mclock.Now() n.processLock.Lock() - defer n.processLock.Unlock() + metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "acquired"}) + defer func() { + n.processLock.Unlock() + metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "released"}) + timeElapsed := mclock.Now() - startTime + metricBlockProcessingLockDuration().Observe(time.Duration(timeElapsed).Milliseconds()) + }() if blockNum > n.maxBlockNum { if blockNum > n.maxBlockNum+1 { From 0e504303378fbbd34c6071f179d2797beb0845e2 Mon Sep 17 00:00:00 2001 From: Miguel Angel Rojo Fernandez Date: Fri, 10 Jan 2025 12:47:59 +0000 Subject: [PATCH 2/3] first commit --- cmd/thor/node/node.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/thor/node/node.go b/cmd/thor/node/node.go index 2b0eb36b3..4b15db26c 100644 --- a/cmd/thor/node/node.go +++ b/cmd/thor/node/node.go @@ -280,8 +280,8 @@ func (n *Node) guardBlockProcessing(blockNum uint32, process func(conflicts uint defer func() { n.processLock.Unlock() metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "released"}) - timeElapsed := mclock.Now() - startTime - metricBlockProcessingLockDuration().Observe(time.Duration(timeElapsed).Milliseconds()) + lockElapsed := mclock.Now() - startTime + metricBlockProcessingLockDuration().Observe(time.Duration(lockElapsed).Milliseconds()) }() if blockNum > n.maxBlockNum { From f3cebdd9887be2a4adececf1f3acf48b4603cd93 Mon Sep 17 00:00:00 2001 From: Miguel Angel Rojo Fernandez Date: Fri, 10 Jan 2025 12:51:58 +0000 Subject: [PATCH 3/3] first commit --- cmd/thor/node/node.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/thor/node/node.go b/cmd/thor/node/node.go index 4b15db26c..f648e7755 100644 --- a/cmd/thor/node/node.go +++ b/cmd/thor/node/node.go @@ -274,13 +274,13 @@ func (n *Node) txStashLoop(ctx context.Context) { // guardBlockProcessing adds lock on block processing and maintains block conflicts. func (n *Node) guardBlockProcessing(blockNum uint32, process func(conflicts uint32) error) error { - startTime := mclock.Now() n.processLock.Lock() + startTime := mclock.Now() metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "acquired"}) defer func() { n.processLock.Unlock() - metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "released"}) lockElapsed := mclock.Now() - startTime + metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "released"}) metricBlockProcessingLockDuration().Observe(time.Duration(lockElapsed).Milliseconds()) }()