Skip to content

Commit 0580ee0

Browse files
committed
Adapt memory usage estimation for flushing
1 parent 013a56a commit 0580ee0

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/txdb.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class CBlockIndex;
1919
class CCoinsViewDBCursor;
2020
class uint256;
2121

22-
//! Compensate for extra memory peak (x1.5-x1.9) at flush time.
23-
static constexpr int DB_PEAK_USAGE_FACTOR = 2;
2422
//! No need to periodic flush if at least this much space still available.
25-
static constexpr int MAX_BLOCK_COINSDB_USAGE = 10 * DB_PEAK_USAGE_FACTOR;
23+
static constexpr int MAX_BLOCK_COINSDB_USAGE = 10;
2624
//! -dbcache default (MiB)
2725
static const int64_t nDefaultDbCache = 450;
2826
//! -dbbatchsize default (bytes)

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
17811781
nLastSetChain = nNow;
17821782
}
17831783
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1784-
int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * DB_PEAK_USAGE_FACTOR;
1784+
int64_t cacheSize = pcoinsTip->DynamicMemoryUsage();
17851785
int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0);
17861786
// The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
17871787
bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024);

0 commit comments

Comments
 (0)