Bump dbcache to 1 GiB #34692

pull andrewtoth wants to merge 4 commits into bitcoin:master from andrewtoth:bump_dbcache changing 6 files +25 −4
  1. andrewtoth commented at 2:25 pm on February 27, 2026: contributor

    Alternative to #34641

    This increases the default dbcache value from 450MiB to 1024MiB if:

    • dbcache is unset
    • The system is 64 bit
    • At least 4GiB of RAM is detected

    Otherwise fallback to previous 450MiB default.

    This should be simple enough to get into v31. The bump to 1GiB shows significant performance increases in #34641. It also alleviates concerns of too high default for steady state, and of lowering the current dbcache for systems with less RAM.

    This change only changes bitcoind behavior, while kernel still defaults to 450 MiB.

  2. DrahtBot commented at 2:26 pm on February 27, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sipa, ajtowns
    Concept ACK kevkevinpal

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34641 (node: scale default -dbcache with system RAM by l0rinc)
    • #34435 (refactor: use _MiB/_GiB consistently for byte conversions by l0rinc)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. andrewtoth force-pushed on Feb 27, 2026
  4. DrahtBot added the label CI failed on Feb 27, 2026
  5. DrahtBot commented at 2:35 pm on February 27, 2026: contributor

    🚧 At least one of the CI tasks failed. Task 32 bit ARM: https://github.com/bitcoin/bitcoin/actions/runs/22490076628/job/65149651058 LLM reason (✨ experimental): C++ compile error: constexpr evaluation fails due to throwing in a constexpr context (MiB value too large for size_t).

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  6. DrahtBot removed the label CI failed on Feb 27, 2026
  7. in src/node/caches.cpp:40 in 6b0210ebe2
    36@@ -37,6 +37,11 @@ size_t CalculateDbCacheBytes(const ArgsManager& args)
    37         constexpr auto max_db_cache{sizeof(void*) == 4 ? MAX_32BIT_DBCACHE : std::numeric_limits<size_t>::max()};
    38         return std::max<size_t>(MIN_DB_CACHE, std::min<uint64_t>(db_cache_bytes, max_db_cache));
    39     }
    40+    if constexpr (sizeof(void*) != 4) {
    


    ajtowns commented at 10:57 am on February 28, 2026:
    Would suggest using if constexpr (sizeof(void*) >= 8) { similar to dbwrapper.cpp (which uses < 8) here.
  8. in src/node/caches.cpp:41 in 6b0210ebe2
    36@@ -37,6 +37,11 @@ size_t CalculateDbCacheBytes(const ArgsManager& args)
    37         constexpr auto max_db_cache{sizeof(void*) == 4 ? MAX_32BIT_DBCACHE : std::numeric_limits<size_t>::max()};
    38         return std::max<size_t>(MIN_DB_CACHE, std::min<uint64_t>(db_cache_bytes, max_db_cache));
    39     }
    40+    if constexpr (sizeof(void*) != 4) {
    41+        if (const auto total_ram{GetTotalRAM()}; total_ram && *total_ram >= HIGH_DEFAULT_DBCACHE_MIN_TOTAL_RAM) {
    


    ajtowns commented at 10:58 am on February 28, 2026:
    if ((GetTotalRAM().value_or(0)) >= HD_DBC_M_T_R) { ?
  9. in src/qt/optionsmodel.cpp:472 in 6b0210ebe2
    468@@ -469,7 +469,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
    469                suffix.empty()          ? getOption(option, "-prev") :
    470                                          DEFAULT_PRUNE_TARGET_GB;
    471     case DatabaseCache:
    472-        return qlonglong(SettingTo<int64_t>(setting(), DEFAULT_DB_CACHE >> 20));
    473+        return qlonglong(SettingTo<int64_t>(setting(), HIGH_DEFAULT_DBCACHE >> 20));
    


    ajtowns commented at 11:05 am on February 28, 2026:
    Perhaps having a size_t DefaultDBCache() { ... } that performs the RAM logic and is also used here would make sense?
  10. in src/init.cpp:506 in 6b0210ebe2
    502@@ -503,7 +503,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
    503     argsman.AddArg("-conf=<file>", 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);
    504     argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
    505     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);
    506-    argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> 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);
    507+    argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d (%d if less than %d MiB system RAM detected)). 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, HIGH_DEFAULT_DBCACHE >> 20, DEFAULT_DB_CACHE >> 20, HIGH_DEFAULT_DBCACHE_MIN_TOTAL_RAM >> 20), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
    


    ajtowns commented at 11:09 am on February 28, 2026:
    Could just leave the memory detection to the .md file and report default: %d as whatever the default on the system is.
  11. ajtowns commented at 11:11 am on February 28, 2026: contributor
    Having a fairly simple bump to the dbcache seems better than adding scaling logic to me, fwiw (hi insta).
  12. kevkevinpal commented at 3:02 pm on February 28, 2026: contributor

    Concept ACK 6b0210e

    I agree with Ajtowns, I think it makes more sense to have a simple bump in cache size instead of auto scaling.

  13. kevkevinpal commented at 3:11 pm on February 28, 2026: contributor
    We might want to add a release note since this will affect any nodes that currently do not have -dbcache set running on systems with greater than 4 GB RAM
  14. 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.
    5b34f25184
  15. andrewtoth force-pushed on Feb 28, 2026
  16. qt: show GetDefaultDBCache() in settings 027cac8527
  17. doc: update dbcache default in reduce-memory.md c510d126ef
  18. andrewtoth force-pushed on Feb 28, 2026
  19. DrahtBot added the label CI failed on Feb 28, 2026
  20. DrahtBot commented at 3:45 pm on February 28, 2026: contributor

    🚧 At least one of the CI tasks failed. Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/22523590140/job/65252087815 LLM reason (✨ experimental): Build failed during the Qt target (src/qt/optionsmodel.cpp) with a non-zero exit status from the cmake/make step.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  21. doc: add release notes for dbcache bump 4ae9a10ada
  22. andrewtoth force-pushed on Feb 28, 2026
  23. sipa commented at 3:53 pm on February 28, 2026: member
    ACK 4ae9a10ada95ab8c1ab01472948d348d9538f3bb
  24. andrewtoth commented at 3:55 pm on February 28, 2026: contributor
    Thanks @ajtowns I took all your suggestions. Thanks @kevkevinpal added release notes.
  25. ajtowns commented at 5:06 pm on February 28, 2026: contributor

    ACK 4ae9a10ada95ab8c1ab01472948d348d9538f3bb

    Checked it gives 450 on a system with less than 4GB and 1024 on a system with more.

  26. DrahtBot removed the label CI failed on Mar 2, 2026
  27. hodlinator commented at 10:05 pm on March 2, 2026: contributor

    If you want to avoid changing kernel behavior in this PR, it would be good to state so in the PR-description. “This change only changes bitcoind behavior, while kernel still defaults to 450 MiB.” https://github.com/bitcoin/bitcoin/blob/2702711c3a54b2ba9ae3781b61c90d28ee951de6/src/kernel/bitcoinkernel.cpp#L463 https://github.com/bitcoin/bitcoin/blob/2702711c3a54b2ba9ae3781b61c90d28ee951de6/src/kernel/bitcoinkernel.cpp#L1013


    Please also use the correct “GiB” unit in PR title. (Edit: and correct all units in the PR description).

  28. andrewtoth renamed this:
    Bump dbcache to 1GB
    Bump dbcache to 1 GiB
    on Mar 2, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-04 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me