load a full finality worth of state during warmup

This commit is contained in:
vyzo 2021-07-25 12:25:42 +03:00
parent 11d3f19a5b
commit 0fd8fc24e1
2 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import (
func init() { func init() {
CompactionThreshold = 5 CompactionThreshold = 5
CompactionBoundary = 2 CompactionBoundary = 2
WarmupBoundary = 0
logging.SetLogLevel("splitstore", "DEBUG") logging.SetLogLevel("splitstore", "DEBUG")
} }

View File

@ -10,9 +10,15 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
bstore "github.com/filecoin-project/lotus/blockstore" bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
) )
var (
// WarmupBoundary is the number of epochs to load state during warmup.
WarmupBoundary = build.Finality
)
// warmup acuiqres the compaction lock and spawns a goroutine to warm up the hotstore; // warmup acuiqres the compaction lock and spawns a goroutine to warm up the hotstore;
// this is necessary when we sync from a snapshot or when we enable the splitstore // this is necessary when we sync from a snapshot or when we enable the splitstore
// on top of an existing blockstore (which becomes the coldstore). // on top of an existing blockstore (which becomes the coldstore).
@ -44,11 +50,12 @@ func (s *SplitStore) warmup(curTs *types.TipSet) error {
// objects are written in batches so as to minimize overhead. // objects are written in batches so as to minimize overhead.
func (s *SplitStore) doWarmup(curTs *types.TipSet) error { func (s *SplitStore) doWarmup(curTs *types.TipSet) error {
epoch := curTs.Height() epoch := curTs.Height()
boundaryEpoch := epoch - WarmupBoundary
batchHot := make([]blocks.Block, 0, batchSize) batchHot := make([]blocks.Block, 0, batchSize)
count := int64(0) count := int64(0)
xcount := int64(0) xcount := int64(0)
missing := int64(0) missing := int64(0)
err := s.walkChain(curTs, epoch, epoch+1, // we don't load messages/receipts in warmup err := s.walkChain(curTs, boundaryEpoch, epoch+1, // we don't load messages/receipts in warmup
func(c cid.Cid) error { func(c cid.Cid) error {
if isUnitaryObject(c) { if isUnitaryObject(c) {
return errStopWalk return errStopWalk