use functional options for hotstore gc, rename MovingGC to FullGC
This commit is contained in:
parent
96c1123c33
commit
9d25464703
@ -82,12 +82,12 @@ type Config struct {
|
|||||||
// for which messages will be retained in the hotstore.
|
// for which messages will be retained in the hotstore.
|
||||||
HotStoreMessageRetention uint64
|
HotStoreMessageRetention uint64
|
||||||
|
|
||||||
// HotstoreMovingGCFrequency indicates how frequently to garbage collect the hotstore using
|
// HotstoreFullGCFrequency indicates how frequently (in terms of compactions) to garbage collect
|
||||||
// moving GC (if supported by the hotstore).
|
// the hotstore using full (moving) GC if supported by the hotstore.
|
||||||
// A value of 0 disables moving GC entirely.
|
// A value of 0 disables full GC entirely.
|
||||||
// A positive value is the number of compactions before a moving GC is performed;
|
// A positive value is the number of compactions before a full GC is performed;
|
||||||
// a value of 1 will perform moving GC in every compaction.
|
// a value of 1 will perform full GC in every compaction.
|
||||||
HotStoreMovingGCFrequency uint64
|
HotStoreFullGCFrequency uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainAccessor allows the Splitstore to access the chain. It will most likely
|
// ChainAccessor allows the Splitstore to access the chain. It will most likely
|
||||||
|
@ -8,11 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *SplitStore) gcHotstore() {
|
func (s *SplitStore) gcHotstore() {
|
||||||
var opts map[interface{}]interface{}
|
var opts []bstore.BlockstoreGCOption
|
||||||
if s.cfg.HotStoreMovingGCFrequency > 0 && s.compactionIndex%int64(s.cfg.HotStoreMovingGCFrequency) == 0 {
|
if s.cfg.HotStoreFullGCFrequency > 0 && s.compactionIndex%int64(s.cfg.HotStoreFullGCFrequency) == 0 {
|
||||||
opts = map[interface{}]interface{}{
|
opts = append(opts, bstore.WithFullGC(true))
|
||||||
bstore.BlockstoreMovingGC: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.gcBlockstore(s.hot, opts); err != nil {
|
if err := s.gcBlockstore(s.hot, opts); err != nil {
|
||||||
@ -20,12 +18,12 @@ func (s *SplitStore) gcHotstore() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SplitStore) gcBlockstore(b bstore.Blockstore, opts map[interface{}]interface{}) error {
|
func (s *SplitStore) gcBlockstore(b bstore.Blockstore, opts []bstore.BlockstoreGCOption) error {
|
||||||
if gc, ok := b.(bstore.BlockstoreGC); ok {
|
if gc, ok := b.(bstore.BlockstoreGC); ok {
|
||||||
log.Info("garbage collecting blockstore")
|
log.Info("garbage collecting blockstore")
|
||||||
startGC := time.Now()
|
startGC := time.Now()
|
||||||
|
|
||||||
if err := gc.CollectGarbage(opts); err != nil {
|
if err := gc.CollectGarbage(opts...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func DefaultFullNode() *FullNode {
|
|||||||
HotStoreType: "badger",
|
HotStoreType: "badger",
|
||||||
MarkSetType: "map",
|
MarkSetType: "map",
|
||||||
|
|
||||||
HotStoreMovingGCFrequency: 20,
|
HotStoreFullGCFrequency: 20,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -291,10 +291,10 @@ type Splitstore struct {
|
|||||||
// HotStoreMessageRetention specifies the retention policy for messages, in finalities beyond
|
// HotStoreMessageRetention specifies the retention policy for messages, in finalities beyond
|
||||||
// the compaction boundary; default is 0.
|
// the compaction boundary; default is 0.
|
||||||
HotStoreMessageRetention uint64
|
HotStoreMessageRetention uint64
|
||||||
// HotStoreMovingGCFrequency specifies how often to perform moving GC on the hotstore.
|
// HotStoreFullGCFrequency specifies how often to perform a full (moving) GC on the hotstore.
|
||||||
// A value of 0 disables, while a value 1 will do moving GC in every compaction.
|
// A value of 0 disables, while a value 1 will do full GC in every compaction.
|
||||||
// Default is 20 (about once a week).
|
// Default is 20 (about once a week).
|
||||||
HotStoreMovingGCFrequency uint64
|
HotStoreFullGCFrequency uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Full Node
|
// // Full Node
|
||||||
|
@ -78,10 +78,10 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg := &splitstore.Config{
|
cfg := &splitstore.Config{
|
||||||
MarkSetType: cfg.Splitstore.MarkSetType,
|
MarkSetType: cfg.Splitstore.MarkSetType,
|
||||||
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "discard",
|
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "discard",
|
||||||
HotStoreMessageRetention: cfg.Splitstore.HotStoreMessageRetention,
|
HotStoreMessageRetention: cfg.Splitstore.HotStoreMessageRetention,
|
||||||
HotStoreMovingGCFrequency: cfg.Splitstore.HotStoreMovingGCFrequency,
|
HotStoreFullGCFrequency: cfg.Splitstore.HotStoreFullGCFrequency,
|
||||||
}
|
}
|
||||||
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user