simplify compaction model

This commit is contained in:
vyzo 2021-07-04 10:06:55 +03:00
parent 5f7ae1f489
commit 6fa2cd232d

View File

@ -35,25 +35,20 @@ var (
// //
// |················· CompactionThreshold ··················| // |················· CompactionThreshold ··················|
// | | // | |
// =======‖≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡‖----------|------------------------» // =======‖≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡‖------------------------»
// | | | chain --> ↑__ current epoch // | | chain --> ↑__ current epoch
// | archived epochs ___↑ | // | archived epochs ___↑
// | ↑________ CompactionBoundary // ↑________ CompactionBoundary
// ↑__ CompactionSlack
// //
// === :: cold (already archived) // === :: cold (already archived)
// ≡≡≡ :: to be archived in this compaction // ≡≡≡ :: to be archived in this compaction
// --- :: hot // --- :: hot
CompactionThreshold = 7 * build.Finality CompactionThreshold = 6 * build.Finality
// CompactionBoundary is the number of epochs from the current epoch at which // CompactionBoundary is the number of epochs from the current epoch at which
// we will walk the chain for live objects. // we will walk the chain for live objects.
CompactionBoundary = 4 * build.Finality CompactionBoundary = 4 * build.Finality
// CompactionSlack is the number of epochs from the compaction boundary to the beginning
// of the cold epoch.
CompactionSlack = 2 * build.Finality
// SyncGapTime is the time delay from a tipset's min timestamp before we decide // SyncGapTime is the time delay from a tipset's min timestamp before we decide
// there is a sync gap // there is a sync gap
SyncGapTime = time.Minute SyncGapTime = time.Minute
@ -775,9 +770,8 @@ func (s *SplitStore) compact(curTs *types.TipSet) {
func (s *SplitStore) doCompact(curTs *types.TipSet) error { func (s *SplitStore) doCompact(curTs *types.TipSet) error {
currentEpoch := curTs.Height() currentEpoch := curTs.Height()
boundaryEpoch := currentEpoch - CompactionBoundary boundaryEpoch := currentEpoch - CompactionBoundary
coldEpoch := boundaryEpoch - CompactionSlack
log.Infow("running compaction", "currentEpoch", currentEpoch, "baseEpoch", s.baseEpoch, "coldEpoch", coldEpoch, "boundaryEpoch", boundaryEpoch) log.Infow("running compaction", "currentEpoch", currentEpoch, "baseEpoch", s.baseEpoch, "boundaryEpoch", boundaryEpoch)
markSet, err := s.markSetEnv.Create("live", s.markSetSize) markSet, err := s.markSetEnv.Create("live", s.markSetSize)
if err != nil { if err != nil {
@ -793,7 +787,7 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
s.txnLk.Unlock() s.txnLk.Unlock()
// 1. mark reachable objects by walking the chain from the current epoch to the boundary epoch // 1. mark reachable objects by walking the chain from the current epoch to the boundary epoch
log.Infow("marking reachable blocks", "currentEpoch", currentEpoch, "boundaryEpoch", boundaryEpoch) log.Info("marking reachable blocks")
startMark := time.Now() startMark := time.Now()
var count int64 var count int64
@ -944,7 +938,7 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
// we are done; do some housekeeping // we are done; do some housekeeping
s.gcHotstore() s.gcHotstore()
err = s.setBaseEpoch(coldEpoch) err = s.setBaseEpoch(boundaryEpoch)
if err != nil { if err != nil {
return xerrors.Errorf("error saving base epoch: %w", err) return xerrors.Errorf("error saving base epoch: %w", err)
} }