Skip to content

Commit

Permalink
e3: aggressive pruning (erigontech#7070)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored and calmbeing committed Mar 16, 2023
1 parent 1215e19 commit 5f817d6
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,16 @@ func ExecV3(ctx context.Context,
progress.Log(rs, rwsLen, uint64(queueSize), rs.DoneCount(), inputBlockNum.Load(), outputBlockNum.Get(), outputTxNum.Load(), repeatCount.Load(), uint64(resultsSize.Load()), resultCh, stepsInDB)
case <-pruneEvery.C:
if rs.SizeEstimate() < commitThreshold {
// too much steps in db will slow-down everything: flush and prune
// it means better spend time for pruning, before flushing more data to db
// also better do it now - instead of before Commit() - because Commit does block execution
stepsInDB := rawdbhelpers.IdxStepsCountV3(tx)
if stepsInDB > 5 && rs.SizeEstimate() < uint64(float64(commitThreshold)*0.2) {
if err = agg.Prune(ctx, ethconfig.HistoryV3AggregationStep*2); err != nil { // prune part of retired data, before commit
if agg.CanPrune(tx) {
log.Warn("Aggressive prune")
if err = agg.Prune(ctx, ethconfig.HistoryV3AggregationStep/10); err != nil { // prune part of retired data, before commit
panic(err)
}
}

if err = agg.Flush(ctx, tx); err != nil {
return err
}
if err = agg.PruneWithTiemout(ctx, 1*time.Second); err != nil {
return err
} else {
log.Warn("No aggressive prune")
if err = agg.Flush(ctx, tx); err != nil {
return err
}
}
break
}
Expand Down

0 comments on commit 5f817d6

Please sign in to comment.