skip moving cold blocks when running with a noop coldstore

it is a noop but it still takes (a lot of) time because it has to read all the cold blocks.
This commit is contained in:
vyzo 2021-07-02 22:34:00 +03:00
parent b87295db93
commit 68bc5d2291
2 changed files with 19 additions and 11 deletions

View File

@ -102,6 +102,12 @@ type Config struct {
// This is necessary, and automatically set by DI in lotus node construction, if
// you are running with a noop coldstore.
HotHeaders bool
// SkipMoveColdBlocks indicates whether to skip moving cold blocks to the coldstore.
// If the splitstore is running with a noop coldstore then this option is set to true
// which skips moving (as it is a noop, but still takes time to read all the cold objects)
// and directly purges cold blocks.
SkipMoveColdBlocks bool
}
// ChainAccessor allows the Splitstore to access the chain. It will most likely
@ -1055,7 +1061,8 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
return xerrors.Errorf("compaction aborted")
}
// 2.2 copy the cold objects to the coldstore
// 2.2 copy the cold objects to the coldstore -- if we have one
if !s.cfg.SkipMoveColdBlocks {
log.Info("moving cold blocks to the coldstore")
startMove := time.Now()
err = s.moveColdBlocks(cold)
@ -1063,7 +1070,7 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
return xerrors.Errorf("error moving cold blocks: %w", err)
}
log.Infow("moving done", "took", time.Since(startMove))
}
// 2.3 purge cold objects from the hotstore
log.Info("purging cold objects from the hotstore")
startPurge := time.Now()

View File

@ -81,6 +81,7 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
TrackingStoreType: cfg.Splitstore.TrackingStoreType,
MarkSetType: cfg.Splitstore.MarkSetType,
HotHeaders: cfg.Splitstore.HotHeaders || cfg.Splitstore.ColdStoreType == "noop",
SkipMoveColdBlocks: cfg.Splitstore.ColdStoreType == "noop",
}
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
if err != nil {