Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.
Alternative to #11359
Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.
3390 | @@ -3391,6 +3391,15 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight 3391 | int count=0; 3392 | 3393 | if (nCurrentUsage + nBuffer >= nPruneTarget) { 3394 | + // On a prune event, the chainstate DB is flushed. 3395 | + // To avoid excessive prune events negating the benefit of high dbcache 3396 | + // values, we should not prune too rapidly. 3397 | + // So when pruning in IBD, increase the buffer a bit to avoid a re-prune too soon. 3398 | + if (IsInitialBlockDownload()) { 3399 | + // Since this is only relevant during IBD, we use a fixed 10%
BTW, why 10%, in IBD could be even more no?
Some IRC discussion.
tACK ac51a26 (although I rebased it on master).
This performs better than master in my tests so far: #12404 (comment) @promag wrote:
BTW, why 10%, in IBD could be even more no?
I tried this in #12404 and there seems to be negative side effects that I can't explain. I'd say this PR is a safer choice for now. @luke-jr you may want to borrow the release note I added to my PR, though that can be done later.
I'm currently racing two Orange Pi's with 2 GB memory. This PR means cache rarely grows beyond 300 MB, but it's still a bit faster than master; after 5 days it's at 2018-01-27 vs. master is still at 2017-11-25.
utACK ac51a26bdc69dc35e1f4f89b62c3134047e93bc1. This should be a safe first improvement. We can later make the overshoot value configurable or smarter, but this should already be a lot better.
utACK ac51a26. Improvement looks good.
utACK ac51a26bdc69dc35e1f4f89b62c3134047e93bc1
utACK ac51a26bdc69dc35e1f4f89b62c3134047e93bc1
Post-merge tested ACK.
I ran this on some memory-constrained Linodes (dbcache=1000, prune=5000, and both connect= to a single nearby fully synced node; 2GB memory, 50GB disk), and saw a reasonably consistent 15% performance increase compared to not having this patch.
How use this ?
@martinpgaunt it just works, if you download Bitcoin Core 0.17 when it comes out in a couple of weeks (or a bit later).