avoid extraneous assignment

This commit is contained in:
vyzo 2022-01-26 21:48:03 +02:00
parent fe47d6a1a4
commit a87239e802

View File

@ -700,14 +700,7 @@ func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEp
return err return err
} }
// the walk is BFS, so we can reset the walked set in every iteration and avoid building up workers := len(toWalk)
// a set that contains all blocks (1M epochs -> 5M blocks -> 200MB worth of memory and growing
// over time)
walked = newConcurrentVisitor()
walking := toWalk
toWalk = nil
workers := len(walking)
if workers > runtime.NumCPU()/2 { if workers > runtime.NumCPU()/2 {
workers = runtime.NumCPU() / 2 workers = runtime.NumCPU() / 2
} }
@ -715,11 +708,16 @@ func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEp
workers = 2 workers = 2
} }
workch := make(chan cid.Cid, len(walking)) // the walk is BFS, so we can reset the walked set in every iteration and avoid building up
for _, c := range walking { // a set that contains all blocks (1M epochs -> 5M blocks -> 200MB worth of memory and growing
// over time)
walked = newConcurrentVisitor()
workch := make(chan cid.Cid, len(toWalk))
for _, c := range toWalk {
workch <- c workch <- c
} }
close(workch) close(workch)
toWalk = nil
g := new(errgroup.Group) g := new(errgroup.Group)
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {