Skip to content

Commit

Permalink
E3: Minimal fix to E3 pruning (#10338)
Browse files Browse the repository at this point in the history
Co-authored-by: awskii <[email protected]>
  • Loading branch information
Giulio2002 and awskii authored May 14, 2024
1 parent 65ba9b4 commit 1432f4d
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,15 @@ Loop:
}
t1 = time.Since(tt)

tt = time.Now()

if !useExternalTx {
if _, err := applyTx.(state2.HasAggTx).AggTx().(*state2.AggregatorRoTx).PruneSmallBatches(ctx, 10*time.Minute, applyTx); err != nil {
return err
}
}
t3 = time.Since(tt)

if err := func() error {
doms.Close()
if err = execStage.Update(applyTx, outputBlockNum.GetValueUint64()); err != nil {
Expand All @@ -890,21 +899,6 @@ Loop:
agg.BuildFilesInBackground(outputTxNum.Load())
}

aggCtx := agg.BeginFilesRo()
defer aggCtx.Close()

tt = time.Now()
for haveMoreToPrune := true; haveMoreToPrune; {
//very aggressive prune, because:
// if prune is slow - means DB > RAM and skip pruning will only make things worse
// db will grow -> prune will get slower -> db will grow -> ...
if haveMoreToPrune, err = aggCtx.PruneSmallBatchesDb(ctx, 10*time.Minute, chainDb); err != nil {
return err
}
}

t3 = time.Since(tt)

applyTx, err = cfg.db.BeginRw(context.Background()) //nolint
if err != nil {
return err
Expand Down

0 comments on commit 1432f4d

Please sign in to comment.