@@ -151,10 +151,12 @@ func (s *Store[H]) delete(ctx context.Context, height uint64, batch datastore.Ba
151
151
return nil
152
152
}
153
153
154
- var deleteTimeoutError = errors .New ("delete timeout" )
154
+ // workerNum defines how many parallel delete workers to run
155
+ // Scales of number of CPUs configred for the process.
156
+ var workerNum = runtime .GOMAXPROCS (- 1 ) * 4
155
157
156
- // it gracefully handles context and errors
157
- // attempting to save interrupted progress.
158
+ // deleteParallel deletes [from:to) header range from the store in parallel.
159
+ // It gracefully handles context and errors attempting to save interrupted progress.
158
160
func (s * Store [H ]) deleteParallel (ctx context.Context , from , to uint64 ) (err error ) {
159
161
log .Debugw ("starting delete range parallel" , "from_height" , from , "to_height" , to )
160
162
@@ -181,14 +183,14 @@ func (s *Store[H]) deleteParallel(ctx context.Context, from, to uint64) (err err
181
183
"from_height" , from ,
182
184
"expected_to_height" , to ,
183
185
"actual_to_height" , newTailHeight ,
184
- "took" , time .Since (startTime ),
186
+ "took(s) " , time .Since (startTime ),
185
187
)
186
188
} else {
187
189
log .Errorw ("partial delete with error" ,
188
190
"from_height" , from ,
189
191
"expected_to_height" , to ,
190
192
"actual_to_height" , newTailHeight ,
191
- "took" , time .Since (startTime ),
193
+ "took(s) " , time .Since (startTime ),
192
194
"err" , err ,
193
195
)
194
196
}
@@ -205,7 +207,6 @@ func (s *Store[H]) deleteParallel(ctx context.Context, from, to uint64) (err err
205
207
onDelete := slices .Clone (s .onDelete )
206
208
s .onDeleteMu .Unlock ()
207
209
208
- workerNum := runtime .NumCPU () * 4
209
210
jobCh := make (chan uint64 , workerNum )
210
211
errCh := make (chan error , 1 )
211
212
@@ -277,3 +278,5 @@ func (s *Store[H]) deleteParallel(ctx context.Context, from, to uint64) (err err
277
278
close (jobCh )
278
279
return err
279
280
}
281
+
282
+ var deleteTimeoutError = errors .New ("delete timeout" )
0 commit comments