Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
caches_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or https://opensource.org/license/mit.
4
5
#include <
kernel/caches.h
>
6
#include <
node/caches.h
>
7
#include <
util/byte_units.h
>
8
9
#include <boost/test/unit_test.hpp>
10
11
#include <cstdint>
12
13
using namespace
node
;
14
15
namespace
{
16
void
CheckDbCacheWarnThreshold(uint64_t threshold, uint64_t total_ram)
17
{
18
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(threshold, total_ram));
19
BOOST_CHECK
(
ShouldWarnOversizedDbCache
(threshold + 1, total_ram));
20
}
21
}
// namespace
22
23
BOOST_AUTO_TEST_SUITE(caches_tests)
24
25
BOOST_AUTO_TEST_CASE
(oversized_dbcache_warning)
26
{
27
BOOST_CHECK
(!
ShouldWarnOversizedDbCache
(
MIN_DBCACHE_BYTES
, 1_GiB));
28
29
// Below DBCACHE_WARNING_RESERVED_RAM the existing fixed default dominates.
30
CheckDbCacheWarnThreshold(
DEFAULT_KERNEL_CACHE
, 1_GiB);
31
CheckDbCacheWarnThreshold(
DEFAULT_KERNEL_CACHE
,
DBCACHE_WARNING_RESERVED_RAM
);
32
33
// Above DBCACHE_WARNING_RESERVED_RAM the warning fires at 75% of the headroom.
34
CheckDbCacheWarnThreshold(((3_GiB -
DBCACHE_WARNING_RESERVED_RAM
) / 4) * 3, 3_GiB);
35
36
for
(
const
auto
total_ram : {8_GiB, 16_GiB, 32_GiB}) {
37
CheckDbCacheWarnThreshold(((total_ram -
DBCACHE_WARNING_RESERVED_RAM
) / 4) * 3, total_ram);
38
}
39
}
40
41
BOOST_AUTO_TEST_SUITE_END
()
byte_units.h
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(ipc_tests)
Definition
ipc_tests.cpp:202
caches.h
DEFAULT_KERNEL_CACHE
constexpr uint64_t DEFAULT_KERNEL_CACHE
Suggested default amount of cache reserved for the kernel (bytes).
Definition
caches.h:19
MIN_DBCACHE_BYTES
constexpr uint64_t MIN_DBCACHE_BYTES
Minimum total database cache (bytes).
Definition
caches.h:15
node
Definition
messages.h:21
node::ShouldWarnOversizedDbCache
constexpr bool ShouldWarnOversizedDbCache(uint64_t dbcache, uint64_t total_ram) noexcept
Definition
caches.h:32
caches.h
DBCACHE_WARNING_RESERVED_RAM
constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM
Reserved non-dbcache memory usage.
Definition
caches.h:18
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition
object.cpp:16
Generated on
for Bitcoin Core by
1.18.0