validation: warn on undersized -dbcache #35865

pull ptrinh wants to merge 1 commits into bitcoin:master from ptrinh:2026-08-warn-undersized-dbcache changing 4 files +62 −0
  1. ptrinh commented at 3:58 AM on August 2, 2026: none

    Since #33333 we warn at startup when -dbcache is likely too large for the system's memory. This adds the symmetric runtime hint for the opposite misconfiguration: a -dbcache too small for the node's working set.

    When the coins cache grows past its size limit outside of IBD (CoinsCacheSizeState::LARGE on a periodic flush, or CRITICAL during block connection), it is fully emptied rather than synced. On a long-running node this is easy to hit with a small -dbcache, and it has a real cost: the cache never stays warm, block connection slows down, and every eviction cycle rewrites a large part of the UTXO set into LevelDB, causing compaction churn and sustained write amplification on the underlying disk.

    Today this situation is invisible unless the user runs with -debug=coindb or attaches to the Linux-only utxocache:flush tracepoint. I recently diagnosed a stock Umbrel node (dbcache=450 with txindex and blockfilterindex enabled) whose container had averaged roughly 2 MB/s of disk writes over three weeks while fully synced at tip. The only clue in default logs was the cache= value in UpdateTip lines sitting pinned at the same number for hours. A one-line hint would have made that diagnosis trivial, and would point the many node-in-a-box users running overridden defaults at the actual fix.

    The warning:

    • only fires for a size-pressure eviction (not FORCE_FLUSH, not periodic syncs, not prune flushes),
    • is suppressed during IBD, where filling the cache is expected,
    • is suppressed for historical (assumeutxo background) chainstates, and
    • is logged at most once per run to avoid log spam.

    The new functional test fills a 4 MiB coins cache past its limit with MiniWallet transactions and checks that the warning appears.

  2. validation: warn on undersized -dbcache
    When the coins cache grows past its size limit outside of IBD
    (CoinsCacheSizeState::LARGE on a periodic flush, or CRITICAL during
    block connection), it is fully emptied rather than synced. On a
    long-running node this usually means -dbcache is undersized for the
    node's working set: the cache never stays warm, block connection slows
    down, and every eviction cycle rewrites a large part of the UTXO set
    into LevelDB, causing repeated compactions and sustained write
    amplification on the underlying disk.
    
    This situation is currently only visible with -debug=coindb or the
    Linux-only utxocache:flush tracepoint. Log a one-time warning when a
    size-pressure eviction happens on a non-historical chainstate outside
    of initial block download, pointing the user at -dbcache.
    
    This complements 5aec516b2c (warn on oversized -dbcache), which covers
    the opposite misconfiguration at startup.
    ec29338552
  3. DrahtBot added the label Validation on Aug 2, 2026
  4. DrahtBot commented at 3:58 AM on August 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35865.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. andrewtoth commented at 4:10 AM on August 2, 2026: contributor

    The 2mb/s of writes was fixed by https://github.com/bitcoin-core/leveldb-subtree/pull/61. A small dbcache value during steady state would not cause more writing. The cache is written to disk every hour regardless of cache size. Wiping the cache would cause more reads.

    This reads like ai slop.

  6. ptrinh closed this on Aug 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-08-10 11:50 UTC

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