From 5b34f251847a3c66b444959800b70e9863b10bbe Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Fri, 27 Feb 2026 09:17:00 -0500 Subject: [PATCH 1/4] dbcache: bump default from 450MB -> 1024MB if enough memory If dbcache is unset, bump default from 450MB to 1024MB on 64-bit systems that have at least 4GB of detected RAM. --- src/init.cpp | 2 +- src/node/caches.cpp | 16 +++++++++++++++- src/node/caches.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index adc1dacc757..417546058d4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -503,7 +503,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc) argsman.AddArg("-conf=", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS); argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", DEFAULT_DB_CACHE_BATCH), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); - argsman.AddArg("-dbcache=", strprintf("Maximum database cache size MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DB_CACHE >> 20, DEFAULT_DB_CACHE >> 20), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-dbcache=", strprintf("Maximum database cache size MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DB_CACHE >> 20, node::GetDefaultDBCache() >> 20), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-includeconf=", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-allowignoredconf", strprintf("For backwards compatibility, treat an unused %s file in the datadir as a warning, not an error.", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-loadblock=", "Imports blocks from external file on startup", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/node/caches.cpp b/src/node/caches.cpp index 5e285e8907b..cb8afbc967d 100644 --- a/src/node/caches.cpp +++ b/src/node/caches.cpp @@ -27,8 +27,22 @@ static constexpr size_t MAX_FILTER_INDEX_CACHE{1024_MiB}; static constexpr size_t MAX_TXOSPENDER_INDEX_CACHE{1024_MiB}; //! Maximum dbcache size on 32-bit systems. static constexpr size_t MAX_32BIT_DBCACHE{1024_MiB}; +//! Larger default dbcache on 64-bit systems with enough RAM. +static constexpr size_t HIGH_DEFAULT_DBCACHE{1024_MiB}; +//! Minimum detected RAM required for HIGH_DEFAULT_DBCACHE. +static constexpr uint64_t HIGH_DEFAULT_DBCACHE_MIN_TOTAL_RAM{4096ULL << 20}; namespace node { +size_t GetDefaultDBCache() +{ + if constexpr (sizeof(void*) >= 8) { + if (GetTotalRAM().value_or(0) >= HIGH_DEFAULT_DBCACHE_MIN_TOTAL_RAM) { + return HIGH_DEFAULT_DBCACHE; + } + } + return DEFAULT_DB_CACHE; +} + size_t CalculateDbCacheBytes(const ArgsManager& args) { if (auto db_cache{args.GetIntArg("-dbcache")}) { @@ -37,7 +51,7 @@ size_t CalculateDbCacheBytes(const ArgsManager& args) constexpr auto max_db_cache{sizeof(void*) == 4 ? MAX_32BIT_DBCACHE : std::numeric_limits::max()}; return std::max(MIN_DB_CACHE, std::min(db_cache_bytes, max_db_cache)); } - return DEFAULT_DB_CACHE; + return GetDefaultDBCache(); } CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes) diff --git a/src/node/caches.h b/src/node/caches.h index 8ea2fbffc0b..62f097411ba 100644 --- a/src/node/caches.h +++ b/src/node/caches.h @@ -18,6 +18,7 @@ static constexpr size_t MIN_DB_CACHE{4_MiB}; static constexpr size_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE}; namespace node { +size_t GetDefaultDBCache(); struct IndexCacheSizes { size_t tx_index{0}; size_t filter_index{0}; From 027cac852796f643e2b6036fd3652dd3ca7785a5 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Fri, 27 Feb 2026 09:18:41 -0500 Subject: [PATCH 2/4] qt: show GetDefaultDBCache() in settings --- src/qt/optionsmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index cfbc350f091..d52c65d6aeb 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -469,7 +469,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con suffix.empty() ? getOption(option, "-prev") : DEFAULT_PRUNE_TARGET_GB; case DatabaseCache: - return qlonglong(SettingTo(setting(), DEFAULT_DB_CACHE >> 20)); + return qlonglong(SettingTo(setting(), node::GetDefaultDBCache() >> 20)); case ThreadsScriptVerif: return qlonglong(SettingTo(setting(), DEFAULT_SCRIPTCHECK_THREADS)); case Listen: From c510d126efb6ce9623e0e005829c13a110f65b0e Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Fri, 27 Feb 2026 09:20:06 -0500 Subject: [PATCH 3/4] doc: update dbcache default in reduce-memory.md --- doc/reduce-memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/reduce-memory.md b/doc/reduce-memory.md index cac5dc982d1..9a7e7452f2e 100644 --- a/doc/reduce-memory.md +++ b/doc/reduce-memory.md @@ -6,7 +6,7 @@ There are a few parameters that can be dialed down to reduce the memory usage of The size of some in-memory caches can be reduced. As caches trade off memory usage for performance, reducing these will usually have a negative effect on performance. -- `-dbcache=` - the UTXO database cache size, this defaults to `450`. The unit is MiB (1024). +- `-dbcache=` - the UTXO database cache size, this defaults to `1024` (or `450` if less than `4096` MiB system RAM is detected). The unit is MiB (1024). - The minimum value for `-dbcache` is 4. - A lower `-dbcache` makes initial sync time much longer. After the initial sync, the effect is less pronounced for most use-cases, unless fast validation of blocks is important, such as for mining. From 4ae9a10ada95ab8c1ab01472948d348d9538f3bb Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Sat, 28 Feb 2026 10:44:25 -0500 Subject: [PATCH 4/4] doc: add release notes for dbcache bump --- doc/release-notes-34692.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/release-notes-34692.md diff --git a/doc/release-notes-34692.md b/doc/release-notes-34692.md new file mode 100644 index 00000000000..0336dfaf99e --- /dev/null +++ b/doc/release-notes-34692.md @@ -0,0 +1,6 @@ +## Updated settings + +- The default `-dbcache` value has been increased to `1024` MiB from `450` MiB + on systems where at least `4096` MiB of RAM is detected. + This is a performance increase, but will use more memory. + To maintain the previous behaviour, set `-dbcache=450`.