Skip to content

Commit

Permalink
chore: decrease num of blocksync workers to 4 * numCPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Mar 19, 2024
1 parent a2d26af commit 05b7eb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/blocksync/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"runtime"
"sync/atomic"
"time"

Expand Down Expand Up @@ -33,12 +34,11 @@ eg, L = latency = 0.1s

const (
requestInterval = 2 * time.Millisecond
poolWorkerSize = 600
maxPendingRequestsPerPeer = 20

// Minimum recv rate to ensure we're receiving blocks from a peer fast
// enough. If a peer is not sending us data at at least that rate, we
// consider them to have timedout and we disconnect.
// consider them to have timed out and we disconnect.
//
// Assuming a DSL connection (not a good choice) 128 Kbps (upload) ~ 15 KB/s,
// sending data across atlantic ~ 7.5 KB/s.
Expand All @@ -56,14 +56,15 @@ const (
are not at peer limits, we can probably switch to consensus reactor
*/

// Synchronizer keeps track of the block sync peers, block requests and block responses.
type (
PeerAdder interface {
AddPeer(peer PeerData)
}
PeerRemover interface {
RemovePeer(peerID types.NodeID)
}

// Synchronizer keeps track of the block sync peers, block requests and block responses.
Synchronizer struct {
service.BaseService
logger log.Logger
Expand Down Expand Up @@ -113,6 +114,9 @@ func WithClock(clock clockwork.Clock) OptionFunc {

// NewSynchronizer returns a new Synchronizer with the height equal to start
func NewSynchronizer(start int64, client client.BlockClient, blockExec *blockApplier, opts ...OptionFunc) *Synchronizer {
// we default to 4 * numCPU workers
poolWorkerSize := runtime.NumCPU() * 4

peerStore := NewInMemPeerStore()
logger := log.NewNopLogger()
bp := &Synchronizer{
Expand Down
2 changes: 2 additions & 0 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
}

txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas)
num_txs_requested := txs.Len()
block := state.MakeBlock(height, txs, commit, evidence, proposerProTxHash, proposedAppVersion)

localLastCommit := buildLastCommitInfo(block, state.InitialHeight)
Expand Down Expand Up @@ -252,6 +253,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
"response_hash", hex.EncodeToString(respHash),
"height", height,
"round", round,
"requested_txs", num_txs_requested,
"took", time.Since(start).String(),
)
if bytes.Equal(blockExec.lastRequestPrepareProposalHash, reqHash) &&
Expand Down

0 comments on commit 05b7eb2

Please sign in to comment.