24 constexpr bool is_64_bit =
sizeof(
void*) == 8;
27 auto& view = chainstate.CoinsTip();
33 constexpr unsigned int COIN_SIZE = is_64_bit ? 80 : 64;
36 BOOST_TEST_MESSAGE(
"CCoinsViewCache memory usage: " << view.DynamicMemoryUsage());
40 constexpr size_t MAX_COINS_CACHE_BYTES = 262144 + 512;
49 if (view.DynamicMemoryUsage() != 32 && view.DynamicMemoryUsage() != 16) {
52 for (
int i{0}; i < 1000; ++i) {
58 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
61 BOOST_TEST_MESSAGE(
"Exiting cache flush tests early due to unsupported arch");
65 print_view_mem_usage(view);
72 constexpr int COINS_UNTIL_CRITICAL{3};
76 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
79 for (
int i{0}; i < COINS_UNTIL_CRITICAL; ++i) {
81 print_view_mem_usage(view);
87 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
92 for (
int i{0}; i < 4; ++i) {
94 print_view_mem_usage(view);
95 if (chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0) ==
102 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
107 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 1 << 19),
110 for (
int i{0}; i < 3; ++i) {
112 print_view_mem_usage(view);
114 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 1 << 19),
121 print_view_mem_usage(view);
125 float usage_percentage = (float)view.DynamicMemoryUsage() / (MAX_COINS_CACHE_BYTES + (1 << 10));
126 BOOST_TEST_MESSAGE(
"CoinsTip usage percentage: " << usage_percentage);
130 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 1 << 10),
135 for (
int i{0}; i < 1000; ++i) {
138 chainstate.GetCoinsCacheSizeState(),
145 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
150 print_view_mem_usage(view);
153 chainstate.GetCoinsCacheSizeState(MAX_COINS_CACHE_BYTES, 0),
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::unique_ptr< ChainstateManager > chainman