From e4ad73bcb4cbec85e077779ce5a004c9cf02650e Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 28 Sep 2022 13:05:26 +0700 Subject: [PATCH] erigon3: agg to use workers for compress and merge (#5561) --- cmd/lightclient/sentinel/sentinel.go | 6 +++--- eth/stagedsync/stage_execute.go | 1 + go.mod | 4 ++-- go.sum | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/lightclient/sentinel/sentinel.go b/cmd/lightclient/sentinel/sentinel.go index af78cd488..4b5a7efa7 100644 --- a/cmd/lightclient/sentinel/sentinel.go +++ b/cmd/lightclient/sentinel/sentinel.go @@ -32,7 +32,7 @@ import ( "github.com/pkg/errors" ) -var disconnectPeerCh = make(chan peer.ID, 0) +var disconnectPeerCh = make(chan peer.ID) type Sentinel struct { started bool @@ -120,14 +120,14 @@ func (s *Sentinel) createListener() (*discover.UDPv5, error) { } go func() { + Loop: for { select { case <-s.ctx.Done(): close(disconnectPeerCh) - break + break Loop case pid := <-disconnectPeerCh: s.peers.DisconnectPeer(pid) - default: } } }() diff --git a/eth/stagedsync/stage_execute.go b/eth/stagedsync/stage_execute.go index 70648979e..baf4299d4 100644 --- a/eth/stagedsync/stage_execute.go +++ b/eth/stagedsync/stage_execute.go @@ -246,6 +246,7 @@ func ExecBlock22(s *StageState, u Unwinder, tx kv.RwTx, toBlock uint64, ctx cont if !initialCycle { workersCount = 1 } + cfg.agg.SetWorkers(cmp.Max(1, runtime.NumCPU()-1)) allSnapshots := cfg.blockReader.(WithSnapshots).Snapshots() if initialCycle { diff --git a/go.mod b/go.mod index 19f139239..cab13a048 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/gballet/go-verkle v0.0.0-20220923150140-6c08cd337774 - github.com/ledgerwatch/erigon-lib v0.0.0-20220927105429-e1860348b274 + github.com/ledgerwatch/erigon-lib v0.0.0-20220928022226-79a16394b334 github.com/ledgerwatch/erigon-snapshot v1.0.1-0.20220913092204-de54ee30c7b9 github.com/ledgerwatch/log/v3 v3.4.2 github.com/ledgerwatch/secp256k1 v1.0.0 @@ -49,6 +49,7 @@ require ( github.com/kevinburke/go-bindata v3.21.0+incompatible github.com/libp2p/go-libp2p v0.23.2 github.com/libp2p/go-libp2p-core v0.20.1 + github.com/libp2p/go-libp2p-pubsub v0.8.1 github.com/multiformats/go-multiaddr v0.7.0 github.com/nxadm/tail v1.4.9-0.20211216163028-4472660a31a6 github.com/pelletier/go-toml v1.9.5 @@ -112,7 +113,6 @@ require ( github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect - github.com/libp2p/go-libp2p-pubsub v0.8.1 // indirect github.com/libp2p/go-mplex v0.7.0 // indirect github.com/libp2p/go-msgio v0.2.0 // indirect github.com/libp2p/go-nat v0.1.0 // indirect diff --git a/go.sum b/go.sum index 4f906e8f1..e664ae6c3 100644 --- a/go.sum +++ b/go.sum @@ -559,8 +559,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20220927105429-e1860348b274 h1:uxS/Fefrhj/RuiyEhhG36KsTAk+3pzMx3p3+lA8sH5Y= -github.com/ledgerwatch/erigon-lib v0.0.0-20220927105429-e1860348b274/go.mod h1:nMyol2RVCPF0TSR/VU4bK40JB35R/Q+IdodGW8j1kzU= +github.com/ledgerwatch/erigon-lib v0.0.0-20220928022226-79a16394b334 h1:ktdhRuhARcRUDuZI+FNeuoceSy6iCXziitUSnay5Vcs= +github.com/ledgerwatch/erigon-lib v0.0.0-20220928022226-79a16394b334/go.mod h1:nMyol2RVCPF0TSR/VU4bK40JB35R/Q+IdodGW8j1kzU= github.com/ledgerwatch/erigon-snapshot v1.0.1-0.20220913092204-de54ee30c7b9 h1:iWjzYLtOsp/Wpo9ZWV/eMIlnFzk8bm7POSzrXAILw24= github.com/ledgerwatch/erigon-snapshot v1.0.1-0.20220913092204-de54ee30c7b9/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/log/v3 v3.4.2 h1:chvjB7c100rlIFgPv+Col2eerxIrHL88OiZRuPZDkxw=