Skip to content

Commit d623b3f

Browse files
committed
allow configuring paralelism
1 parent 8a7e8ca commit d623b3f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cmd/migration-checker/main.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
var accountsDone atomic.Uint64
23-
var trieCheckers = make(chan struct{}, runtime.GOMAXPROCS(0)*4)
23+
var trieCheckers chan struct{}
2424

2525
type dbs struct {
2626
zkDb *leveldb.Database
@@ -29,11 +29,12 @@ type dbs struct {
2929

3030
func main() {
3131
var (
32-
mptDbPath = flag.String("mpt-db", "", "path to the MPT node DB")
33-
zkDbPath = flag.String("zk-db", "", "path to the ZK node DB")
34-
mptRoot = flag.String("mpt-root", "", "root hash of the MPT node")
35-
zkRoot = flag.String("zk-root", "", "root hash of the ZK node")
36-
paranoid = flag.Bool("paranoid", false, "verifies all node contents against their expected hash")
32+
mptDbPath = flag.String("mpt-db", "", "path to the MPT node DB")
33+
zkDbPath = flag.String("zk-db", "", "path to the ZK node DB")
34+
mptRoot = flag.String("mpt-root", "", "root hash of the MPT node")
35+
zkRoot = flag.String("zk-root", "", "root hash of the ZK node")
36+
paranoid = flag.Bool("paranoid", false, "verifies all node contents against their expected hash")
37+
parallelismMultipler = flag.Int("parallelism-multiplier", 4, "multiplier for the number of parallel workers")
3738
)
3839
flag.Parse()
3940

@@ -45,7 +46,9 @@ func main() {
4546
zkRootHash := common.HexToHash(*zkRoot)
4647
mptRootHash := common.HexToHash(*mptRoot)
4748

48-
for i := 0; i < runtime.GOMAXPROCS(0)*4; i++ {
49+
numTrieCheckers := runtime.GOMAXPROCS(0) * (*parallelismMultipler)
50+
trieCheckers = make(chan struct{}, numTrieCheckers)
51+
for i := 0; i < numTrieCheckers; i++ {
4952
trieCheckers <- struct{}{}
5053
}
5154

@@ -68,7 +71,7 @@ func main() {
6871
mptDb: mptDb,
6972
}, zkRootHash, mptRootHash, "", checkAccountEquality, true, *paranoid)
7073

71-
for i := 0; i < runtime.GOMAXPROCS(0)*4; i++ {
74+
for i := 0; i < numTrieCheckers; i++ {
7275
<-trieCheckers
7376
}
7477
}

0 commit comments

Comments
 (0)