File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -1511,10 +1511,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15111511 nTotalCache = std::max (nTotalCache, nMinDbCache << 20 ); // total cache cannot be less than nMinDbCache
15121512 nTotalCache = std::min (nTotalCache, nMaxDbCache << 20 ); // total cache cannot be greated than nMaxDbcache
15131513 int64_t nBlockTreeDBCache = nTotalCache / 8 ;
1514- if (nBlockTreeDBCache > (1 << 21 ) && !GetBoolArg (" -txindex" , DEFAULT_TXINDEX))
1515- nBlockTreeDBCache = (1 << 21 ); // block tree db cache shouldn't be larger than 2 MiB
1514+ nBlockTreeDBCache = std::min (nBlockTreeDBCache, (GetBoolArg (" -txindex" , DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20 );
15161515 nTotalCache -= nBlockTreeDBCache;
15171516 int64_t nCoinDBCache = std::min (nTotalCache / 2 , (nTotalCache / 4 ) + (1 << 23 )); // use 25%-50% of the remainder for disk cache
1517+ nCoinDBCache = std::min (nCoinDBCache, nMaxCoinsDBCache << 20 ); // cap total coins db cache
15181518 nTotalCache -= nCoinDBCache;
15191519 nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
15201520 LogPrintf (" Cache configuration:\n " );
Original file line number Diff line number Diff line change @@ -23,11 +23,19 @@ class CCoinsViewDBCursor;
2323class uint256 ;
2424
2525// ! -dbcache default (MiB)
26- static const int64_t nDefaultDbCache = 100 ;
27- // ! max. -dbcache in (MiB)
26+ static const int64_t nDefaultDbCache = 300 ;
27+ // ! max. -dbcache (MiB)
2828static const int64_t nMaxDbCache = sizeof (void *) > 4 ? 16384 : 1024 ;
29- // ! min. -dbcache in (MiB)
29+ // ! min. -dbcache (MiB)
3030static const int64_t nMinDbCache = 4 ;
31+ // ! Max memory allocated to block tree DB specific cache, if no -txindex (MiB)
32+ static const int64_t nMaxBlockDBCache = 2 ;
33+ // ! Max memory allocated to block tree DB specific cache, if -txindex (MiB)
34+ // Unlike for the UTXO database, for the txindex scenario the leveldb cache make
35+ // a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
36+ static const int64_t nMaxBlockDBAndTxIndexCache = 1024 ;
37+ // ! Max memory allocated to coin DB specific cache (MiB)
38+ static const int64_t nMaxCoinsDBCache = 8 ;
3139
3240struct CDiskTxPos : public CDiskBlockPos
3341{
You can’t perform that action at this time.
0 commit comments