From a87239e80218590cf68c2b1d3b653280ba5c9e35 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 26 Jan 2022 21:48:03 +0200 Subject: [PATCH] avoid extraneous assignment --- blockstore/splitstore/splitstore_compact.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/blockstore/splitstore/splitstore_compact.go b/blockstore/splitstore/splitstore_compact.go index ae47cf9a0..9ab718929 100644 --- a/blockstore/splitstore/splitstore_compact.go +++ b/blockstore/splitstore/splitstore_compact.go @@ -700,14 +700,7 @@ func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEp return err } - // the walk is BFS, so we can reset the walked set in every iteration and avoid building up - // 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) + workers := len(toWalk) if 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 } - workch := make(chan cid.Cid, len(walking)) - for _, c := range walking { + // the walk is BFS, so we can reset the walked set in every iteration and avoid building up + // 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 } close(workch) + toWalk = nil g := new(errgroup.Group) for i := 0; i < workers; i++ {