-
Notifications
You must be signed in to change notification settings - Fork 37.7k
During IBD, prune as much as possible until we get close to where we will eventually keep blocks #20827
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
Interesting, will have a look. |
Nice! |
I also like the idea of temporally assigning more RAM for IBD. This could even be done by default for GUI users (with opt-out in the intro screen). |
|
🕵️ @sipa has been requested to review this pull request as specified in the REVIEWERS file. |
src/validation.cpp
Outdated
// So when pruning in IBD, increase the buffer to avoid a re-prune too soon. | ||
if (is_ibd && target_sync_height > (uint64_t)chain_tip_height) { | ||
// Since this is only relevant during IBD, we assume blocks are at least 1 MB on average | ||
static constexpr uint64_t average_block_size = 1000000; /* 1 MB */ |
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.
AFAIK we don't have access to future block sizes at this point.
Without rebase, compiling fails for me: $ make clean && ./configure CXXFLAGS="-O0 -g" CFLAGS="-O0 -g" && make -j 9
...
touch src/config/bitcoin-config.h.in
CXX util/libbitcoin_util_a-moneystr.o
CXX util/libbitcoin_util_a-readwritefile.o
CXX util/libbitcoin_util_a-settings.o
CXX util/libbitcoin_util_a-serfloat.o
CXX util/libbitcoin_util_a-spanparsing.o
CXX util/libbitcoin_util_a-strencodings.o
CXX util/libbitcoin_util_a-string.o
CXX util/libbitcoin_util_a-url.o
make[3]: *** No rule to make target `libunivalue.la'. Stop.
make[2]: *** [univalue/libunivalue.la] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1 After |
@stickies-v If you want to compile older commits of master, you'll need to |
Note: It's usually best to merge PRs into master for testing. Sometimes (bugfixes) they can be based on very old commits (when the bug was introduced); and if there's a silent problem with the merge, you'd want to notice that too.
Can we fix this build system bug? |
Concept ACK |
Concept ACK We'll be doing a Bitcoin Core PR Review club covering this PR on the 29th: bitcoincore.reviews/20827 |
2e42050 doc: fix undo data filename (s/undo???.dat/rev???.dat/) (Sebastian Falbesoner) Pull request description: This typo was discovered in the course of a review club to #20827, see https://bitcoincore.reviews/20827#l-31. ACKs for top commit: shaavan: ACK 2e42050 Tree-SHA512: 0c7a00dce24c03bee6d37265d5b4bc97e976c3f3910af1113f967f6298940f892d6fb517f7b154f32ccedb365060314d4d78d5eb2a9c68b25f0859a628209cd3
…?.dat/) 2e42050 doc: fix undo data filename (s/undo???.dat/rev???.dat/) (Sebastian Falbesoner) Pull request description: This typo was discovered in the course of a review club to bitcoin#20827, see https://bitcoincore.reviews/20827#l-31. ACKs for top commit: shaavan: ACK 2e42050 Tree-SHA512: 0c7a00dce24c03bee6d37265d5b4bc97e976c3f3910af1113f967f6298940f892d6fb517f7b154f32ccedb365060314d4d78d5eb2a9c68b25f0859a628209cd3
Concept ACK, I read the PR Review Club and will review after rebase. |
fwiw: #23581 moved BlockManager to node/blockstorage, that's where the conflict with master happens. I've rebased this PR in https://github.com/0xB10C/bitcoin/tree/2022-01-lukejr-ibd-prune-max-rebased and started benchmarking 0xB10C@db2a9e7 (PR) vs 0xB10C@2e01b69 (mergebase; MB). I have 8 different prune and dbcache configurations set-up. Each configuration runs three times per binary (PR and MB).
Benchmarks run on a dedicated, properly cooled, and otherwise idle machine with two HDDs in a RAID0. The node syncs from a local node on the same machine and disks (connected via |
With a prune just before IBD, there is more blk and undo data available when running master than with this change. One potential issue that was mentioned during the PR review club: On non-mainnet networks, the 1MB per block assumption doesn't hold. When we prune with a large Might be worth thinking about potential alternatives to increasing the |
The 1 MB per block assumption would mean at least 550 blocks. Testnet has deeper reorgs than that? |
Rebased |
Concept ACK |
Concept ACK |
I have a project that syncs bitcoin core on an external drive and this would really help a lot of people testing it with smaller flash drives and higher RAM. So much so that I've made scripts to do manual pruning (back to 550mib) only when disk space is getting low to emulate this. |
Are you still working on this? |
…will eventually keep blocks
1d23d95
to
d298ff8
Compare
@@ -298,6 +298,7 @@ void BlockManager::FindFilesToPrune( | |||
// Distribute our -prune budget over all chainstates. | |||
const auto target = std::max( | |||
MIN_DISK_SPACE_FOR_BLOCK_FILES, GetPruneTarget() / chainman.GetAll().size()); | |||
const uint64_t target_sync_height = chainman.m_best_header->nHeight; |
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.
nit: Any reason this declaration is up here and not directly above where it is used below?
// Since this is only relevant during IBD, we use a fixed 10% | ||
nBuffer += target / 10; | ||
// So when pruning in IBD, increase the buffer to avoid a re-prune too soon. | ||
const auto chain_tip_height = chain.m_chain.Height(); |
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.
nit: could remove the cast in the next line with
const auto chain_tip_height = chain.m_chain.Height(); | |
const uint64_t chain_tip_height = chain.m_chain.Height(); |
ACK d298ff8 Ran benchmark with hyperfine:
Results were 21% faster on this branch 🚀
|
ACK d298ff8 |
15% improvement in IBD performance in some configurations seems significant enough for a release note, no? |
This should reduce pruning flushes even more, speeding up IBD with pruning on systems that have a sufficient dbcache.
Assumes 1 MB per block between tip and best header chain. Simply adds this to the buffer pruning is trying to leave available, which results in pruning almost everything up until we get close to where we need to be keeping blocks.