Skip to content

Commit ac51a26

Browse files
committed
During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after
Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.
1 parent 9828f9a commit ac51a26

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/validation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,6 +3391,15 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight
33913391
int count=0;
33923392

33933393
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%
3400+
nBuffer += nPruneTarget / 10;
3401+
}
3402+
33943403
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
33953404
nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize;
33963405

0 commit comments

Comments
 (0)