Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization: enlarge p2p buffer size and add some metrics for performance monitor #171

Merged
11 changes: 9 additions & 2 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@ func (pool *LegacyPool) addRemoteSync(tx *types.Transaction) error {
// to the add is finished. Only use this during tests for determinism!
func (pool *LegacyPool) Add(txs []*types.Transaction, local, sync bool) []error {
defer func(t0 time.Time) {
addTimer.UpdateSince(t0)
if len(txs) > 0 {
addTimer.Update(time.Since(t0) / time.Duration(len(txs)))
}
}(time.Now())
// Do not treat as local if local transactions have been disabled
local = local && !pool.config.NoLocals
Expand Down Expand Up @@ -1147,7 +1149,9 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, local, sync bool) []error
pool.mu.Lock()
t0 := time.Now()
newErrs, dirtyAddrs := pool.addTxsLocked(news, local)
addWithLockTimer.UpdateSince(t0)
if len(news) > 0 {
addWithLockTimer.Update(time.Since(t0) / time.Duration(len(news)))
}
pool.mu.Unlock()

var nilSlot = 0
Expand Down Expand Up @@ -1403,6 +1407,9 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
reorgDurationTimer.Update(time.Since(t0))
if reset != nil {
reorgresetTimer.UpdateSince(t0)
if reset.newHead != nil {
log.Info("Transaction pool reorged", "from", reset.oldHead.Number.Uint64(), "to", reset.newHead.Number.Uint64())
}
}
}(time.Now())
defer close(done)
Expand Down
6 changes: 4 additions & 2 deletions eth/protocols/eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ const (

// maxQueuedTxs is the maximum number of transactions to queue up before dropping
// older broadcasts.
maxQueuedTxs = 4096
// we need a higher limit to support 10k txs in a block
maxQueuedTxs = 98304

// maxQueuedTxAnns is the maximum number of transaction announcements to queue up
// before dropping older announcements.
maxQueuedTxAnns = 4096
// we need a higher limit to support 10k txs in a block
maxQueuedTxAnns = 98304

// maxQueuedBlocks is the maximum number of block propagations to queue up before
// dropping broadcasts. There's not much point in queueing stale blocks, so a few
Expand Down
3 changes: 2 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"errors"
"fmt"
mapset "github.com/deckarep/golang-set/v2"
"math/big"
"sync"
"sync/atomic"
"time"

mapset "github.com/deckarep/golang-set/v2"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
Expand Down
Loading