Skip to content

Commit 0eeca35

Browse files
committed
decrease multiplier
1 parent c32c520 commit 0eeca35

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

store/store_delete.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
badger4 "github.com/ipfs/go-ds-badger4"
1616
)
1717

18+
// OnDelete implements [header.Store] interface.
1819
func (s *Store[H]) OnDelete(fn func(context.Context, uint64) error) {
1920
s.onDeleteMu.Lock()
2021
defer s.onDeleteMu.Unlock()
@@ -81,15 +82,20 @@ func (s *Store[H]) DeleteTo(ctx context.Context, to uint64) error {
8182
return nil
8283
}
8384

84-
// deleteRange deletes range of headers defined by from and to
85+
// deleteRangeParallelThreshold defines the threshold for parallel deletion.
86+
// If range is smaller than this threshold, deletion will be performed sequentially.
87+
var deleteRangeParallelThreshold uint64 = 10000
88+
89+
// deleteRange deletes [from:to) header range from the store.
8590
func (s *Store[H]) deleteRange(ctx context.Context, from, to uint64) error {
86-
if to-from < 1000 {
91+
if to-from < deleteRangeParallelThreshold {
8792
return s.deleteSequential(ctx, from, to)
8893
}
8994

9095
return s.deleteParallel(ctx, from, to)
9196
}
9297

98+
// deleteSequential deletes [from:to) header range from the store sequentially.
9399
func (s *Store[H]) deleteSequential(ctx context.Context, from, to uint64) error {
94100
log.Debugw("starting delete range sequential", "from_height", from, "to_height", to)
95101

@@ -153,7 +159,7 @@ func (s *Store[H]) delete(ctx context.Context, height uint64, batch datastore.Ba
153159

154160
// workerNum defines how many parallel delete workers to run
155161
// Scales of number of CPUs configred for the process.
156-
var workerNum = runtime.GOMAXPROCS(-1) * 4
162+
var workerNum = runtime.GOMAXPROCS(-1) * 2
157163

158164
// deleteParallel deletes [from:to) header range from the store in parallel.
159165
// It gracefully handles context and errors attempting to save interrupted progress.

0 commit comments

Comments
 (0)