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.
This commit is contained in:
3 files changed
+11
-11
No files matched your search
+9
-2
@@ -12,16 +12,23 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Unlike for the UTXO database, for the txindex scenario the leveldb cache make
|
||||||
|
// a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
|
||||||
|
//! Max memory allocated to tx index DB specific cache in MiB.
|
||||||
|
static constexpr int64_t MAX_TX_INDEX_CACHE{1024};
|
||||||
|
//! Max memory allocated to all block filter index caches combined in MiB.
|
||||||
|
static constexpr int64_t MAX_FILTER_INDEX_CACHE{1024};
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
|
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
|
||||||
{
|
{
|
||||||
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
|
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
|
||||||
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
|
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
|
||||||
IndexCacheSizes sizes;
|
IndexCacheSizes sizes;
|
||||||
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxTxIndexCache << 20 : 0);
|
sizes.tx_index = std::min(nTotalCache / 8, args.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? MAX_TX_INDEX_CACHE << 20 : 0);
|
||||||
nTotalCache -= sizes.tx_index;
|
nTotalCache -= sizes.tx_index;
|
||||||
if (n_indexes > 0) {
|
if (n_indexes > 0) {
|
||||||
int64_t max_cache = std::min(nTotalCache / 8, max_filter_index_cache << 20);
|
int64_t max_cache = std::min(nTotalCache / 8, MAX_FILTER_INDEX_CACHE << 20);
|
||||||
sizes.filter_index = max_cache / n_indexes;
|
sizes.filter_index = max_cache / n_indexes;
|
||||||
nTotalCache -= sizes.filter_index * n_indexes;
|
nTotalCache -= sizes.filter_index * n_indexes;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -8,14 +8,13 @@
|
|||||||
#include <kernel/caches.h>
|
#include <kernel/caches.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class ArgsManager;
|
class ArgsManager;
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
struct IndexCacheSizes {
|
struct IndexCacheSizes {
|
||||||
int64_t tx_index{0};
|
size_t tx_index{0};
|
||||||
int64_t filter_index{0};
|
size_t filter_index{0};
|
||||||
};
|
};
|
||||||
struct CacheSizes {
|
struct CacheSizes {
|
||||||
IndexCacheSizes index;
|
IndexCacheSizes index;
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ static const int64_t nDefaultDbCache = 450;
|
|||||||
static const int64_t nDefaultDbBatchSize = 16 << 20;
|
static const int64_t nDefaultDbBatchSize = 16 << 20;
|
||||||
//! min. -dbcache (MiB)
|
//! min. -dbcache (MiB)
|
||||||
static const int64_t nMinDbCache = 4;
|
static const int64_t nMinDbCache = 4;
|
||||||
// Unlike for the UTXO database, for the txindex scenario the leveldb cache make
|
|
||||||
// a meaningful difference: https://github.com/bitcoin/bitcoin/pull/8273#issuecomment-229601991
|
|
||||||
//! Max memory allocated to tx index DB specific cache in MiB.
|
|
||||||
static const int64_t nMaxTxIndexCache = 1024;
|
|
||||||
//! Max memory allocated to all block filter index caches combined in MiB.
|
|
||||||
static const int64_t max_filter_index_cache = 1024;
|
|
||||||
|
|
||||||
//! User-controlled performance and debug options.
|
//! User-controlled performance and debug options.
|
||||||
struct CoinsViewOptions {
|
struct CoinsViewOptions {
|
||||||
|
|||||||
Reference in new issue
Block a user