Skip to content

Commit

Permalink
prune: less atomics in loops (#10482)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored May 27, 2024
1 parent 7f4ea16 commit 82279a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion erigon-lib/state/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,6 @@ func (dt *DomainRoTx) Prune(ctx context.Context, rwTx kv.RwTx, step, txFrom, txT
stat.Values++
stat.MaxStep = max(stat.MaxStep, is)
stat.MinStep = min(stat.MinStep, is)
mxPruneSizeDomain.Inc()

k, v, err = keysCursor.Prev()

Expand All @@ -1977,6 +1976,8 @@ func (dt *DomainRoTx) Prune(ctx context.Context, rwTx kv.RwTx, step, txFrom, txT
default:
}
}
mxPruneSizeDomain.AddUint64(stat.Values)

if err := SaveExecV3PruneProgress(rwTx, dt.d.keysTable, nil); err != nil {
return stat, fmt.Errorf("save domain pruning progress: %s, %w", dt.d.filenameBase, err)
}
Expand Down
4 changes: 3 additions & 1 deletion erigon-lib/state/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ func (ht *HistoryRoTx) Prune(ctx context.Context, rwTx kv.RwTx, txFrom, txTo, li
defer valsC.Close()
}

var pruned int
pruneValue := func(k, txnm []byte) error {
txNum := binary.BigEndian.Uint64(txnm)
if txNum >= txTo || txNum < txFrom { //[txFrom; txTo), but in this case idx record
Expand All @@ -1090,9 +1091,10 @@ func (ht *HistoryRoTx) Prune(ctx context.Context, rwTx kv.RwTx, txFrom, txTo, li
}
}

mxPruneSizeHistory.Inc()
pruned++
return nil
}
mxPruneSizeHistory.AddInt(pruned)

if !forced && ht.h.dontProduceHistoryFiles {
forced = true // or index.CanPrune will return false cuz no snapshots made
Expand Down

0 comments on commit 82279a7

Please sign in to comment.