From 32d94d4e85f14670b72beb2ded96b518d78e2dbb Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 30 Jul 2021 10:53:22 +0300 Subject: [PATCH] reset walked set as epoch boundaries are crossed the walk is BFS, so we can do this! --- blockstore/splitstore/splitstore_compact.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blockstore/splitstore/splitstore_compact.go b/blockstore/splitstore/splitstore_compact.go index 7628e2bde..2ae5c9e68 100644 --- a/blockstore/splitstore/splitstore_compact.go +++ b/blockstore/splitstore/splitstore_compact.go @@ -616,7 +616,7 @@ func (s *SplitStore) endTxnProtect() { func (s *SplitStore) walkChain(ts *types.TipSet, inclState, inclMsgs abi.ChainEpoch, visitor ObjectVisitor, f func(cid.Cid) error) error { - walked := cid.NewSet() + var walked *cid.Set toWalk := ts.Cids() walkCnt := 0 scanCnt := 0 @@ -687,6 +687,10 @@ 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 = cid.NewSet() walking := toWalk toWalk = nil for _, c := range walking {