Merge pull request #11269 from filecoin-project/throttle-splitstore-purging

fix: Add time slicing to splitstore purging to reduce lock congestion
This commit is contained in:
Friðrik Ásmundsson 2023-09-18 16:54:30 +00:00 committed by GitHub
commit 8aaa8de975
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -5,6 +5,9 @@
## New features
- feat: Added new tracing API (**HIGHLY EXPERIMENTAL**) supporting two RPC methods: `trace_block` and `trace_replayBlockTransactions` ([filecoin-project/lotus#11100](https://github.com/filecoin-project/lotus/pull/11100))
## Improvements
- fix: Add time slicing to splitstore purging step during compaction to reduce lock congestion [filecoin-project/lotus#11269](https://github.com/filecoin-project/lotus/pull/11269)
# v1.23.3 / 2023-08-01
This feature release of Lotus includes numerous improvements and enhancements for node operators, ETH RPC-providers and storage providers.

View File

@ -66,8 +66,9 @@ var (
)
const (
batchSize = 16384
cidKeySize = 128
batchSize = 16384
cidKeySize = 128
purgeWorkSliceDuration = time.Second
)
func (s *SplitStore) HeadChange(_, apply []*types.TipSet) error {
@ -1372,9 +1373,21 @@ 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 time slicing 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.
elapsed := time.Since(now)
if elapsed > purgeWorkSliceDuration {
// work 1 slice, sleep 4 slices, or 20% utilization
time.Sleep(4 * elapsed)
now = time.Now()
}
return deleteBatch()
}