Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e3: aggressive pruning #7070

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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