From b6d8957abb83f9f49fadcb747656ccea6763a88e Mon Sep 17 00:00:00 2001 From: andyzhang2023 Date: Sat, 12 Oct 2024 16:35:27 +0800 Subject: [PATCH 1/2] make the number of p2p parallel enqueue routines fixable --- eth/handler_eth.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eth/handler_eth.go b/eth/handler_eth.go index 7f36ae722d..a498308c50 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "math/big" + "runtime" "time" "github.com/ethereum/go-ethereum/common" @@ -31,8 +32,8 @@ import ( ) // TxQueueSize is the size of the transaction queue used to enqueue transactions -const ( - TxQueueSize = 16 +var ( + TxQueueSize = runtime.NumCPU() ) // enqueueTx is a channel to enqueue transactions in parallel. From 7c70968f3a501084cc5eefa5a42322e8a97f46ed Mon Sep 17 00:00:00 2001 From: andyzhang2023 Date: Sat, 12 Oct 2024 16:43:20 +0800 Subject: [PATCH 2/2] make the number of p2p parallel enqueue routines fixable --- eth/handler_eth.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/handler_eth.go b/eth/handler_eth.go index a498308c50..9b38fbb255 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/fetcher" "github.com/ethereum/go-ethereum/eth/protocols/eth" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/enode" ) @@ -41,6 +42,7 @@ var ( var enqueueTx = make(chan func(), TxQueueSize) func init() { + log.Info("P2P euqneue parallel thread number", "threadNum", TxQueueSize) // run the transaction enqueuing loop for i := 0; i < TxQueueSize; i++ { go func() {