Bitcoin Core 31.99.0
P2P Digital Currency
caches.h
Go to the documentation of this file.
1// Copyright (c) 2021-present 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 <algorithm>
12#include <cstddef>
13#include <cstdint>
14
15class ArgsManager;
16
18static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB};
19
20namespace node {
21uint64_t GetDefaultDBCache();
23 uint64_t tx_index{0};
24 uint64_t filter_index{0};
25 uint64_t txospender_index{0};
26};
27struct CacheSizes {
30};
31CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
32constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept
33{
34 const uint64_t available_ram{total_ram > DBCACHE_WARNING_RESERVED_RAM ? total_ram - DBCACHE_WARNING_RESERVED_RAM : 0};
35 const uint64_t cap{std::max(DEFAULT_KERNEL_CACHE, (available_ram / 4) * 3)};
36 return dbcache > cap;
37}
38
39void LogOversizedDbCache(const ArgsManager& args) noexcept;
40} // namespace node
41
42#endif // BITCOIN_NODE_CACHES_H
ArgsManager & args
Definition: bitcoind.cpp:280
static constexpr uint64_t DEFAULT_KERNEL_CACHE
Suggested default amount of cache reserved for the kernel (bytes)
Definition: caches.h:19
Definition: messages.h:22
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes)
Definition: caches.cpp:57
void LogOversizedDbCache(const ArgsManager &args) noexcept
Definition: caches.cpp:85
constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept
Definition: caches.h:32
uint64_t GetDefaultDBCache()
Definition: caches.cpp:37
static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM
Reserved non-dbcache memory usage.
Definition: caches.h:18
IndexCacheSizes index
Definition: caches.h:28
kernel::CacheSizes kernel
Definition: caches.h:29
uint64_t txospender_index
Definition: caches.h:25
uint64_t filter_index
Definition: caches.h:24
uint64_t tx_index
Definition: caches.h:23