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%
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.
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.