-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
E35 prune small batches #9088
E35 prune small batches #9088
Conversation
erigon-lib/state/aggregator_v3.go
Outdated
defer cancel() | ||
|
||
for { | ||
if err := ac.Prune(context.Background(), tx, 100); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need check that prune with limit is “consistent” - for example Index.Prune doesn ‘t exit before collector.Load (if limit reached).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for pointing on it
this pulled up few problems with context management and limits as well. |
Since Did not decided yet if prune continuation still make sense or it's better to be removed right now, need to make a few more comparisons. Also this PR raises the question: do we want to prune domains index tables as well (which looks meaningful) or just prune it during Unwind process only. |
|
break | ||
|
||
txNum := binary.BigEndian.Uint64(txnm) | ||
if txNum < stat.MinTxNum { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't understand - does this code lost [from, to)
semantic or not
Follow up to #9031 (comment)
Ordering
AggregatorV3Context
pruning is happening in following order:txFrom <= txn <= txTo
. Progress is going towards bigger txNumbers.Latest()
key which is the biggest key available. We useinverted steps (^step)
as a suffix for domain keys which gives us an opportunity to prune smallest steps first. So, from largest available key and smallest available step going backwards to bigger steps and smaller keys. If for given key we metsavedStep > pruneStep
we safely going toPrevNoDup()
key without scanning and skipping steps.Limiting
Pruning progress obviously changes state therefore affects execution - invalid reads of obsolete values could happen if pruning is broken.
Pruning indices and histories is coupled, since history table is bounded to index key and txn entries. Since index is a mapping
txNum -> {key, key', ...}
, looks easier to limit their pruning bytxNums
at once instead of going through whole list selecting bylimit
keys.AggregatorV3Context.PruneSmallBatches()
always settxFrom=0
since it's purpose to keep db clean but one step at a time.domain pruning is limited by amount of keys removed at once. For slow disks and big db (>150G) domain pruning could be very slow: Database keep growing, slowing down pruning as well to 100.000 kv's per 10min session which is not enough to keep db of a constant size. So, using smaller values for
--batchSize
could solve the problem due to more frequent call of Prune and small changes put into db.Domain can be pruned if
savedPruneProgress
key is not for this table nil, or smallest domain key has values ofsavedStep < pruneStep
in domain files. The downside of looking up onto smallest step is that smallest key not guaranteed to be changed in each step which could give us invalid estimate on smallest available key. Saved prune progress indicates that we did not finished latest cleanup but does not give us step number. Could be used meta tables which would contain such an info (smallest step in table?).takeouts, keep in mind
--batchSize
should be smaller on slower disks (even of size16-64M
) to keep db small. BalancedbatchSize
could increase throughput preserving db size.define available steps in db
--batchSize
is reached, commitment evaluated and puts update into that batch which becomes x1.4-x2 of size