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

prune: less atomics in loops #10482

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
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
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
Loading