Skip to content

Commit 8826cae

Browse files
committed
kernel: Move non-kernel db cache size constants
These have nothing to do with the txdb, so move them out and into the node caches.
1 parent e758b26 commit 8826cae

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/node/caches.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@
1212
#include <algorithm>
1313
#include <string>
1414

15+
// Unlike for the UTXO database, for the txindex scenario the leveldb cache make
16+
// a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
17+
//! Max memory allocated to tx index DB specific cache in MiB.
18+
static constexpr int64_t MAX_TX_INDEX_CACHE{1024};
19+
//! Max memory allocated to all block filter index caches combined in MiB.
20+
static constexpr int64_t MAX_FILTER_INDEX_CACHE{1024};
21+
1522
namespace node {
1623
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
1724
{
1825
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
1926
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
2027
IndexCacheSizes sizes;
21-
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxTxIndexCache << 20 : 0);
28+
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? MAX_TX_INDEX_CACHE << 20 : 0);
2229
nTotalCache -= sizes.tx_index;
2330
if (n_indexes > 0) {
24-
int64_t max_cache = std::min(nTotalCache / 8, max_filter_index_cache << 20);
31+
int64_t max_cache = std::min(nTotalCache / 8, MAX_FILTER_INDEX_CACHE << 20);
2532
sizes.filter_index = max_cache / n_indexes;
2633
nTotalCache -= sizes.filter_index * n_indexes;
2734
}

src/node/caches.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
#include <kernel/caches.h>
99

1010
#include <cstddef>
11-
#include <cstdint>
1211

1312
class ArgsManager;
1413

1514
namespace node {
1615
struct IndexCacheSizes {
17-
int64_t tx_index{0};
18-
int64_t filter_index{0};
16+
size_t tx_index{0};
17+
size_t filter_index{0};
1918
};
2019
struct CacheSizes {
2120
IndexCacheSizes index;

src/txdb.h

-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ static const int64_t nDefaultDbCache = 450;
2727
static const int64_t nDefaultDbBatchSize = 16 << 20;
2828
//! min. -dbcache (MiB)
2929
static const int64_t nMinDbCache = 4;
30-
// Unlike for the UTXO database, for the txindex scenario the leveldb cache make
31-
// a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
32-
//! Max memory allocated to tx index DB specific cache in MiB.
33-
static const int64_t nMaxTxIndexCache = 1024;
34-
//! Max memory allocated to all block filter index caches combined in MiB.
35-
static const int64_t max_filter_index_cache = 1024;
3630

3731
//! User-controlled performance and debug options.
3832
struct CoinsViewOptions {

0 commit comments

Comments
 (0)