aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-05-15 13:39:31 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-05-15 13:43:02 +0200
commit6fb90d898355dc1cec7b2bfb4f38d8503886bafb (patch)
treed9a0c463470611561ce8ad13ec5aa401bf4c2114 /src/init.cpp
parent63e7016566f382ff59fe724d09d556022c897222 (diff)
parent86a5f4b54ebf5f3251f4c172cf9a5041ae43c082 (diff)
downloadbitcoin-6fb90d898355dc1cec7b2bfb4f38d8503886bafb.tar.xz
Merge pull request #6102
86a5f4b Relocate calls to CheckDiskSpace (Alex Morcos) 67708ac Write block index more frequently than cache flushes (Pieter Wuille) b3ed423 Cache tweak and logging improvements (Pieter Wuille) fc684ad Use accurate memory for flushing decisions (Pieter Wuille) 046392d Keep track of memory usage in CCoinsViewCache (Pieter Wuille) 540629c Add memusage.h (Pieter Wuille)
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/init.cpp b/src/init.cpp
index bacc938375..2d75850253 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1061,18 +1061,20 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
// cache size calculations
- size_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20);
- if (nTotalCache < (nMinDbCache << 20))
- nTotalCache = (nMinDbCache << 20); // total cache cannot be less than nMinDbCache
- else if (nTotalCache > (nMaxDbCache << 20))
- nTotalCache = (nMaxDbCache << 20); // total cache cannot be greater than nMaxDbCache
- size_t nBlockTreeDBCache = nTotalCache / 8;
+ int64_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20);
+ nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
+ nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greated than nMaxDbcache
+ int64_t nBlockTreeDBCache = nTotalCache / 8;
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false))
nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
nTotalCache -= nBlockTreeDBCache;
- size_t nCoinDBCache = nTotalCache / 2; // use half of the remaining cache for coindb cache
+ int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
nTotalCache -= nCoinDBCache;
- nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
+ nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
+ LogPrintf("Cache configuration:\n");
+ LogPrintf("* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
+ LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
+ LogPrintf("* Using %.1fMiB for in-memory UTXO set\n", nCoinCacheUsage * (1.0 / 1024 / 1024));
bool fLoaded = false;
while (!fLoaded) {