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

feat(pruner): shared deletion limit #4880

Merged
merged 8 commits into from
Oct 4, 2023
Merged

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Oct 2, 2023

With the addition of headers and transactions pruning for the needs of snapshots, it becomes even harder to manage the batch sizes for pruner, so we both not hit the MDBX freelist issues and still prune the data.

This PR refactors the batch sizes into one shared limit for maximum number of deleted entries per pruner run. Each prune part deletes as much as possible, it decreases the deletion limit, and further parts use new limit. It also means that prune parts now have different priority, because e.g. if receipts, which are pruned first, consume the deletion limit fully, consequent parts won't prune anything.

Tested on both mainnet and sepolia, example log

2023-10-04T18:12:00.521326Z  INFO reth::node::events: Pruner finished tip_block_number=4424545 elapsed=899.944121ms parts={SenderRecovery: (Finished, 0), Receipts: (Finished, 0), ContractLogs: (Finished, 2588), AccountHistory: (Finished, 2976), StorageHistory: (Finished, 18652)}

@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

Merging #4880 (18038b8) into main (ce85e17) will decrease coverage by 0.03%.
Report is 24 commits behind head on main.
The diff coverage is 70.50%.

Impacted file tree graph

Files Coverage Δ
crates/consensus/beacon/src/engine/test_utils.rs 66.99% <100.00%> (-0.22%) ⬇️
crates/interfaces/src/blockchain_tree/error.rs 36.29% <ø> (ø)
crates/interfaces/src/test_utils/generators.rs 98.23% <100.00%> (ø)
crates/primitives/src/chain/spec.rs 97.87% <100.00%> (-0.21%) ⬇️
crates/primitives/src/prune/mod.rs 83.33% <100.00%> (+3.84%) ⬆️
crates/prune/src/event.rs 0.00% <ø> (ø)
crates/storage/provider/src/providers/mod.rs 17.73% <100.00%> (-0.67%) ⬇️
crates/storage/provider/src/providers/snapshot.rs 81.37% <100.00%> (ø)
crates/trie/src/trie_cursor/account_cursor.rs 98.21% <100.00%> (-0.04%) ⬇️
bin/reth/src/node/mod.rs 30.05% <0.00%> (+2.51%) ⬆️
... and 3 more

... and 38 files with indirect coverage changes

Flag Coverage Δ
integration-tests 15.49% <0.71%> (-0.04%) ⬇️
unit-tests 62.62% <70.50%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 32.61% <0.00%> (+0.33%) ⬆️
blockchain tree 80.64% <ø> (+0.19%) ⬆️
pipeline 88.45% <ø> (ø)
storage (db) 73.30% <80.64%> (-0.02%) ⬇️
trie 94.52% <100.00%> (-0.01%) ⬇️
txpool 49.10% <ø> (-0.41%) ⬇️
networking 76.06% <ø> (-0.40%) ⬇️
rpc 57.71% <ø> (-0.08%) ⬇️
consensus 61.05% <100.00%> (-0.02%) ⬇️
revm 28.47% <ø> (-0.08%) ⬇️
payload builder 8.16% <ø> (ø)
primitives 85.41% <100.00%> (+0.11%) ⬆️

@shekhirin shekhirin added C-enhancement New feature or request A-pruning Related to pruning or full node labels Oct 3, 2023
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the explanation makes sense to me.

style nits.

haven't reviewed the provider changes in detail yet, ptal @joshieDo

crates/consensus/beacon/src/engine/test_utils.rs Outdated Show resolved Hide resolved
crates/prune/src/pruner.rs Outdated Show resolved Hide resolved
@shekhirin shekhirin force-pushed the alexey/pruner-deletion-limit branch 3 times, most recently from b257d39 to 7268a77 Compare October 3, 2023 12:12
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@joshieDo
Copy link
Collaborator

joshieDo commented Oct 4, 2023

PR itself lgtm. last_pruned_block_number becomes a confusing name if we consider snapshots though (since it will be at a higher height than the first block to prune from the snapshot) , and we might want to change it in the future.

crates/prune/src/pruner.rs Outdated Show resolved Hide resolved
@shekhirin shekhirin added this pull request to the merge queue Oct 4, 2023
Merged via the queue into main with commit af8e3c9 Oct 4, 2023
23 checks passed
@shekhirin shekhirin deleted the alexey/pruner-deletion-limit branch October 4, 2023 18:23
@shekhirin shekhirin mentioned this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pruning Related to pruning or full node C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants