Skip to content

Commit

Permalink
Add time slicing ot splitstore purging to reduce lock congestion
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrik01 committed Sep 14, 2023
1 parent f06d67c commit d9755df
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blockstore/splitstore/splitstore_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,19 @@ func (s *SplitStore) purge(coldr *ColdSetReader, checkpoint *Checkpoint, markSet
return err
}

now := time.Now()

err := coldr.ForEach(func(c cid.Cid) error {
batch = append(batch, c)
if len(batch) == batchSize {
// add some throttling to the purge as this a very disk I/O heavy operation that
// requires write access to txnLk that may starve other operations that require
// access to the blockstore.
if time.Since(now) > time.Second {
time.Sleep(time.Second)
now = time.Now()
}

return deleteBatch()
}

Expand Down

0 comments on commit d9755df

Please sign in to comment.