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 // This is necessary, and automatically set by DI in lotus node construction, if
// you are running with a noop coldstore. // you are running with a noop coldstore.
HotHeaders bool 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 // ChainAccessor allows the Splitstore to access the chain. It will most likely
@ -1055,15 +1061,16 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
return xerrors.Errorf("compaction aborted") 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
log.Info("moving cold blocks to the coldstore") if !s.cfg.SkipMoveColdBlocks {
startMove := time.Now() log.Info("moving cold blocks to the coldstore")
err = s.moveColdBlocks(cold) startMove := time.Now()
if err != nil { err = s.moveColdBlocks(cold)
return xerrors.Errorf("error moving cold blocks: %w", err) if err != nil {
return xerrors.Errorf("error moving cold blocks: %w", err)
}
log.Infow("moving done", "took", time.Since(startMove))
} }
log.Infow("moving done", "took", time.Since(startMove))
// 2.3 purge cold objects from the hotstore // 2.3 purge cold objects from the hotstore
log.Info("purging cold objects from the hotstore") log.Info("purging cold objects from the hotstore")
startPurge := time.Now() startPurge := time.Now()

View File

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