Skip to content

Commit

Permalink
During IBD, when doing pruning, prune 10% extra to avoid pruning agai…
Browse files Browse the repository at this point in the history
…n soon after

Summary:
Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.

Backport of Bitcoin Core PR11658
bitcoin/bitcoin#11658

Test Plan:
```
make check
```

Reviewers: Fabien, #bitcoin_abc, deadalnix, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D3986
  • Loading branch information
luke-jr authored and fpelliccioni committed Sep 5, 2019
1 parent ec813bc commit 966fa58
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4297,6 +4297,16 @@ static void FindFilesToPrune(std::set<int> &setFilesToPrune,
int count = 0;

if (nCurrentUsage + nBuffer >= nPruneTarget) {
// On a prune event, the chainstate DB is flushed.
// To avoid excessive prune events negating the benefit of high dbcache
// values, we should not prune too rapidly.
// So when pruning in IBD, increase the buffer a bit to avoid a re-prune
// too soon.
if (IsInitialBlockDownload()) {
// Since this is only relevant during IBD, we use a fixed 10%
nBuffer += nPruneTarget / 10;
}

for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
nBytesToPrune = vinfoBlockFile[fileNumber].nSize +
vinfoBlockFile[fileNumber].nUndoSize;
Expand Down

0 comments on commit 966fa58

Please sign in to comment.