diff --git a/blockstore/splitstore/splitstore_compact.go b/blockstore/splitstore/splitstore_compact.go index d406434df..41578351b 100644 --- a/blockstore/splitstore/splitstore_compact.go +++ b/blockstore/splitstore/splitstore_compact.go @@ -694,11 +694,6 @@ func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEp return nil } - workers := runtime.NumCPU() / 2 - if workers < 2 { - workers = 2 - } - for len(toWalk) > 0 { // walking can take a while, so check this with every opportunity if err := s.checkClosing(); err != nil { @@ -712,6 +707,11 @@ func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEp walking := toWalk toWalk = nil + workers := len(walking) + if workers > runtime.NumCPU()/2 { + workers = runtime.NumCPU() / 2 + } + workch := make(chan cid.Cid, len(walking)) for _, c := range walking { workch <- c