diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-05 08:08:02 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-05 08:10:43 +0200 |
commit | 5fc6a77aa6261b23e94eae4c3a9f56dd62895d87 (patch) | |
tree | dadeef3688211e880f9cc1033f7bc4c5f5523ac1 /src/validation.cpp | |
parent | fadf078c9cd70ac930ec1dbbe4d4988ea6a2ba44 (diff) | |
parent | 1b55e07b7a61a9e6c299cf4c40fde80fa715d440 (diff) |
Merge #10133: Clean up calculations of pcoinsTip memory usage
1b55e07 Make threshold for flushing more conservative. (Alex Morcos)
f33afd3 Lower default memory footprint slightly (Alex Morcos)
5b95a19 Make pcoinsTip memory calculations consistent (Alex Morcos)
Tree-SHA512: d0061138596cf89008397b8729d9b25293938b1ad454cc99a6fe2f6210e94f76dfa78a8f0fce4c1ba3efec4e742a9c1a3ab26676a4a8346d3e7c3055d032669b
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 7eae5fd800..1f5b317441 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2006,10 +2006,11 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode, int n nLastSetChain = nNow; } int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; - int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * 2; // Compensate for extra memory peak (x1.5-x1.9) at flush time. + int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * DB_PEAK_USAGE_FACTOR; int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0); - // The cache is large and we're within 10% and 100 MiB of the limit, but we have time now (not in the middle of a block processing). - bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - 100 * 1024 * 1024); + // The cache is large and we're within 10% and 200 MiB or 50% and 50MiB of the limit, but we have time now (not in the middle of a block processing). + bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::min(std::max(nTotalSpace / 2, nTotalSpace - MIN_BLOCK_COINSDB_USAGE * 1024 * 1024), + std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024)); // The cache is over the limit, we have to write now. bool fCacheCritical = mode == FLUSH_STATE_IF_NEEDED && cacheSize > nTotalSpace; // It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash. |