Skip to content

Commit 396f9d6

Browse files
committed
Merge #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)
2 parents 042c323 + efd1d83 commit 396f9d6

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

doc/release-notes.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@ report issues about Windows XP to the issue tracker.
4141
Notable changes
4242
===============
4343

44-
Example item
45-
----------------
44+
Database cache memory increased
45+
--------------------------------
46+
47+
As a result of growth of the UTXO set, performance with the prior default
48+
database cache of 100 MiB has suffered.
49+
For this reason the default was changed to 300 MiB in this release.
50+
51+
For nodes on low-memory systems, the database cache can be changed back to
52+
100 MiB (or to another value) by either:
53+
54+
- Adding `dbcache=100` in bitcoin.conf
55+
- Changing it in the GUI under `Options → Size of database cache`
4656

57+
Note that the database cache setting has the most performance impact
58+
during initial sync of a node, and when catching up after downtime.
4759

4860
bitcoin-cli: arguments privacy
4961
--------------------------------

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,10 +1216,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12161216
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
12171217
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greated than nMaxDbcache
12181218
int64_t nBlockTreeDBCache = nTotalCache / 8;
1219-
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", DEFAULT_TXINDEX))
1220-
nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
1219+
nBlockTreeDBCache = std::min(nBlockTreeDBCache, (GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20);
12211220
nTotalCache -= nBlockTreeDBCache;
12221221
int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
1222+
nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache
12231223
nTotalCache -= nCoinDBCache;
12241224
nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
12251225
LogPrintf("Cache configuration:\n");

src/txdb.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ class CCoinsViewDBCursor;
2222
class uint256;
2323

2424
//! -dbcache default (MiB)
25-
static const int64_t nDefaultDbCache = 100;
26-
//! max. -dbcache in (MiB)
25+
static const int64_t nDefaultDbCache = 300;
26+
//! max. -dbcache (MiB)
2727
static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
28-
//! min. -dbcache in (MiB)
28+
//! min. -dbcache (MiB)
2929
static const int64_t nMinDbCache = 4;
30+
//! Max memory allocated to block tree DB specific cache, if no -txindex (MiB)
31+
static const int64_t nMaxBlockDBCache = 2;
32+
//! Max memory allocated to block tree DB specific cache, if -txindex (MiB)
33+
// Unlike for the UTXO database, for the txindex scenario the leveldb cache make
34+
// a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
35+
static const int64_t nMaxBlockDBAndTxIndexCache = 1024;
36+
//! Max memory allocated to coin DB specific cache (MiB)
37+
static const int64_t nMaxCoinsDBCache = 8;
3038

3139
struct CDiskTxPos : public CDiskBlockPos
3240
{

0 commit comments

Comments
 (0)