Skip to content

Commit e3b7ed4

Browse files
laanwjcodablock
authored andcommitted
Merge bitcoin#8273: Bump -dbcache default to 300MiB
efd1d83 doc: Mention dbcache increase in release notes (Wladimir J. van der Laan) 32cab91 Bump `-dbcache` default to 300MiB (Wladimir J. van der Laan)
1 parent 952383e commit e3b7ed4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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");

src/txdb.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ class CCoinsViewDBCursor;
2323
class 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)
2828
static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
29-
//! min. -dbcache in (MiB)
29+
//! min. -dbcache (MiB)
3030
static 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

3240
struct CDiskTxPos : public CDiskBlockPos
3341
{

0 commit comments

Comments
 (0)