Skip to content

Commit

Permalink
Merge pull request #10391 from filecoin-project/feat/record-hotstore-…
Browse files Browse the repository at this point in the history
…space

feat:splitstore:Configure max space used by hotstore and GC makes best effort to respect
  • Loading branch information
magik6k authored Mar 9, 2023
2 parents c80783d + 366ebe3 commit faedc12
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 64 deletions.
29 changes: 29 additions & 0 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ type Config struct {
// A positive value is the number of compactions before a full GC is performed;
// a value of 1 will perform full GC in every compaction.
HotStoreFullGCFrequency uint64

// HotstoreMaxSpaceTarget suggests the max allowed space the hotstore can take.
// This is not a hard limit, it is possible for the hotstore to exceed the target
// for example if state grows massively between compactions. The splitstore
// will make a best effort to avoid overflowing the target and in practice should
// never overflow. This field is used when doing GC at the end of a compaction to
// adaptively choose moving GC
HotstoreMaxSpaceTarget uint64

// Moving GC will be triggered when total moving size exceeds
// HotstoreMaxSpaceTarget - HotstoreMaxSpaceThreshold
HotstoreMaxSpaceThreshold uint64

// Safety buffer to prevent moving GC from overflowing disk.
// Moving GC will not occur when total moving size exceeds
// HotstoreMaxSpaceTarget - HotstoreMaxSpaceSafetyBuffer
HotstoreMaxSpaceSafetyBuffer uint64
}

// ChainAccessor allows the Splitstore to access the chain. It will most likely
Expand Down Expand Up @@ -165,6 +182,7 @@ type SplitStore struct {

compactionIndex int64
pruneIndex int64
onlineGCCnt int64

ctx context.Context
cancel func()
Expand Down Expand Up @@ -195,6 +213,17 @@ type SplitStore struct {

// registered protectors
protectors []func(func(cid.Cid) error) error

// dag sizes measured during latest compaction
// logged and used for GC strategy

// protected by compaction lock
szWalk int64
szProtectedTxns int64
szKeys int64 // approximate, not counting keys protected when entering critical section

// protected by txnLk
szMarkedLiveRefs int64
}

var _ bstore.Blockstore = (*SplitStore)(nil)
Expand Down
4 changes: 2 additions & 2 deletions blockstore/splitstore/splitstore_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *SplitStore) doCheck(curTs *types.TipSet) error {
}
defer visitor.Close() //nolint

err = s.walkChain(curTs, boundaryEpoch, boundaryEpoch, visitor,
size := s.walkChain(curTs, boundaryEpoch, boundaryEpoch, visitor,
func(c cid.Cid) error {
if isUnitaryObject(c) {
return errStopWalk
Expand Down Expand Up @@ -133,7 +133,7 @@ func (s *SplitStore) doCheck(curTs *types.TipSet) error {
return err
}

log.Infow("check done", "cold", *coldCnt, "missing", *missingCnt)
log.Infow("check done", "cold", *coldCnt, "missing", *missingCnt, "walk size", size)
write("--")
write("cold: %d missing: %d", *coldCnt, *missingCnt)
write("DONE")
Expand Down
Loading

0 comments on commit faedc12

Please sign in to comment.