From 697783061682d062a14b176134b2afedb6e6a363 Mon Sep 17 00:00:00 2001 From: andyzhang2023 Date: Fri, 15 Nov 2024 16:28:32 +0800 Subject: [PATCH] add metrics for bottleneck of txpool: 1. tx packet size from p2p network --- eth/handler_eth.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/handler_eth.go b/eth/handler_eth.go index f10a3b29b..27c526059 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -44,6 +44,7 @@ var ( var enqueueTx = make(chan func(), TxQueueSize) var parallelCounter int32 = 0 var parallelCounterGuage = metrics.NewRegisteredGauge("p2p/enqueue/parallel", nil) +var txPackSizeGuage = metrics.NewRegisteredGauge("p2p/enqueue/tx/pack/size", nil) func init() { log.Info("P2P euqneue parallel thread number", "threadNum", TxQueueSize) @@ -145,6 +146,9 @@ func asyncEnqueueTx(peer *eth.Peer, txs []*types.Transaction, fetcher *fetcher.T return err } enqueueTx <- func() { + if metrics.EnabledExpensive { + txPackSizeGuage.Update(int64(len(txs))) + } if err := fetcher.Enqueue(peer.ID(), txs, directed); err != nil { peer.Log().Warn("Failed to enqueue transaction", "err", err) }