node: smooth oversized `dbcache` warnings #35200

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/smooth-dbcache-warnings changing 2 files +28 −25
  1. l0rinc commented at 12:56 PM on May 3, 2026: contributor

    Problem

    The oversized -dbcache warning threshold has a sharp formula cliff when detected RAM crosses the cutoff used by the warning logic.

    This was reported during review of #34641, where an earlier version could jump from the auto default at 4095 MiB RAM to 75% of RAM at 4096 MiB. That made 1 MiB of extra detected RAM raise the warning threshold from about 511 MiB to 3072 MiB.

    The surviving warning-only code has the same shape at a different boundary. Below 2 GiB RAM the cap is DEFAULT_DB_CACHE (450 MiB), but at 2 GiB it switches to 75% of total RAM, so a tiny increase in detected RAM can suddenly raise the warning threshold from 450 MiB to about 1536 MiB.

    <img width="1484" height="881" alt="Image" src="https://github.com/user-attachments/assets/b51d5d24-31b8-4a2a-8f70-e7536481f855" />

    Fix

    Base the warning on a reserved non-dbcache memory budget instead:

    \text{warn if } \mathit{dbcache} > \max\left(\mathit{DEFAULT\_DB\_CACHE}, 0.75 \cdot \max(\text{total RAM} - \mathit{DBCACHE\_WARNING\_RESERVED\_RAM}, 0)\right)
    

    DBCACHE_WARNING_RESERVED_RAM is 2 GiB, so the fixed DEFAULT_DB_CACHE cap remains the floor below that reserve and the warning threshold grows monotonically above it.

    This keeps the warning conservative around low-memory boundaries and avoids treating a boundary-crossing 1 MiB RAM difference as a reason to allow a much larger explicit -dbcache.

    Quick reference

    System RAM Previous warning cap New warning cap
    1 GiB 450 MiB 450 MiB
    2 GiB 1536 MiB 450 MiB
    3 GiB 2304 MiB 768 MiB
    4 GiB 3072 MiB 1536 MiB
    8 GiB 6144 MiB 4608 MiB
    16 GiB 12288 MiB 10752 MiB
    32 GiB 24576 MiB 23040 MiB

    On 32-bit builds, effective -dbcache values are still capped to 1024 MiB before the warning check, so thresholds above that cap are not reachable there.

  2. node: smooth oversized `-dbcache` warnings
    The oversized dbcache warning still switches from a fixed `450 MiB` cap below `2 GiB` RAM to `75%` of total RAM at `2 GiB`.
    That creates a discontinuity where adding a small amount of RAM can raise the warning threshold from `450 MiB` to `1536 MiB`.
    
    Use a single monotonic rule based on a `2 GiB` reserved-memory budget instead.
    Above `DBCACHE_WARNING_RESERVED_RAM`, the threshold grows linearly at `0.75 MiB` per MiB of additional RAM.
    This keeps a `25%` margin above the reserve for OS and mempool variance while avoiding the cliff.
    
    Co-authored-by: Bortlesboat <Bortlesboat@users.noreply.github.com>
    4705319c99
  3. DrahtBot commented at 12:56 PM on May 3, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. DrahtBot added the label CI failed on May 3, 2026
  5. DrahtBot commented at 1:45 PM on May 3, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/25279789848/job/74115183233</sub> <sub>LLM reason (✨ experimental): CI failed because the CTest “Bitcoin Core Test Suite” had failing tests, specifically sock_tests (1 test failed).</sub>

    <details><summary>Hints</summary>

    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.

    </details>


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-05-04 06:12 UTC

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