LCOV - code coverage report
Current view: top level - src/node - caches.h Coverage Total Hit
Test: total_coverage.info Lines: 100.0 % 3 3
Test Date: 2025-10-04 05:03:45 Functions: - 0 0
Branches: 50.0 % 4 2

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2021 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #ifndef BITCOIN_NODE_CACHES_H
       6                 :             : #define BITCOIN_NODE_CACHES_H
       7                 :             : 
       8                 :             : #include <kernel/caches.h>
       9                 :             : #include <util/byte_units.h>
      10                 :             : 
      11                 :             : #include <cstddef>
      12                 :             : 
      13                 :             : class ArgsManager;
      14                 :             : 
      15                 :             : //! min. -dbcache (bytes)
      16                 :             : static constexpr size_t MIN_DB_CACHE{4_MiB};
      17                 :             : //! -dbcache default (bytes)
      18                 :             : static constexpr size_t DEFAULT_DB_CACHE{DEFAULT_KERNEL_CACHE};
      19                 :             : 
      20                 :             : namespace node {
      21                 :             : struct IndexCacheSizes {
      22                 :             :     size_t tx_index{0};
      23                 :             :     size_t filter_index{0};
      24                 :             : };
      25                 :             : struct CacheSizes {
      26                 :             :     IndexCacheSizes index;
      27                 :             :     kernel::CacheSizes kernel;
      28                 :             : };
      29                 :             : CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
      30                 :        1026 : constexpr bool ShouldWarnOversizedDbCache(size_t dbcache, size_t total_ram) noexcept
      31                 :             : {
      32         [ +  - ]:        1026 :     const size_t cap{(total_ram < 2048_MiB) ? DEFAULT_DB_CACHE : (total_ram / 100) * 75};
      33         [ -  + ]:        1026 :     return dbcache > cap;
      34                 :             : }
      35                 :             : 
      36                 :             : void LogOversizedDbCache(const ArgsManager& args) noexcept;
      37                 :             : } // namespace node
      38                 :             : 
      39                 :             : #endif // BITCOIN_NODE_CACHES_H
        

Generated by: LCOV version 2.0-1