From 2ef8acdfc8c47cb5eb175a8abf8df5b75f11e7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Wed, 2 Dec 2020 21:35:13 +0000 Subject: [PATCH] back out index cache usage in badger blockstore. --- node/repo/blockstore_opts.go | 21 +-------------------- system/resources.go | 4 +++- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/node/repo/blockstore_opts.go b/node/repo/blockstore_opts.go index 3a9fc26df..775b41266 100644 --- a/node/repo/blockstore_opts.go +++ b/node/repo/blockstore_opts.go @@ -1,9 +1,6 @@ package repo -import ( - badgerbs "github.com/filecoin-project/lotus/lib/blockstore/badger" - "github.com/filecoin-project/lotus/system" -) +import badgerbs "github.com/filecoin-project/lotus/lib/blockstore/badger" // BadgerBlockstoreOptions returns the badger options to apply for the provided // domain. @@ -44,22 +41,6 @@ func BadgerBlockstoreOptions(domain BlockstoreDomain, path string, readonly bool // Default table size is already 64MiB. This is here to make it explicit. opts.MaxTableSize = 64 << 20 - // If we don't set an index cache size, badger will retain all indices from - // all tables _in memory_. This is quite counter intuitive, but it's true. - // See badger/table.Table#initIndex. - // - // We vary the cache size depending on the configured system limits, taking - // up to 20% of the configured limit, with a min of 256MiB, and a max - // of 1GiB. - var icachesize int64 - switch icachesize = int64(float64(system.ResourceConstraints.EffectiveMemLimit) * 0.20); { - case icachesize < 256<<20: // 256MiB. - icachesize = 256 << 20 - case icachesize > 1<<30: // 1GiB. - icachesize = 1 << 30 - } - opts.IndexCacheSize = icachesize - // NOTE: The chain blockstore doesn't require any GC (blocks are never // deleted). This will change if we move to a tiered blockstore. diff --git a/system/resources.go b/system/resources.go index 3b9c9a6ea..b486c2c2c 100644 --- a/system/resources.go +++ b/system/resources.go @@ -18,7 +18,9 @@ var ( const EnvMaximumHeap = "LOTUS_MAX_HEAP" // ResourceConstraints represents resource constraints that Lotus and the go -// runtime should abide by. +// runtime should abide by. It is a singleton object that's populated on +// initialization, and can be used by components for size calculations +// (e.g. caches). var ResourceConstraints struct { // MaxHeapMem is the maximum heap memory that has been set by the user // through the LOTUS_MAX_HEAP env variable. If zero, there is no max heap