back out index cache usage in badger blockstore.
This commit is contained in:
parent
e8a5e0d2fe
commit
2ef8acdfc8
@ -1,9 +1,6 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import badgerbs "github.com/filecoin-project/lotus/lib/blockstore/badger"
|
||||||
badgerbs "github.com/filecoin-project/lotus/lib/blockstore/badger"
|
|
||||||
"github.com/filecoin-project/lotus/system"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BadgerBlockstoreOptions returns the badger options to apply for the provided
|
// BadgerBlockstoreOptions returns the badger options to apply for the provided
|
||||||
// domain.
|
// 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.
|
// Default table size is already 64MiB. This is here to make it explicit.
|
||||||
opts.MaxTableSize = 64 << 20
|
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
|
// NOTE: The chain blockstore doesn't require any GC (blocks are never
|
||||||
// deleted). This will change if we move to a tiered blockstore.
|
// deleted). This will change if we move to a tiered blockstore.
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ var (
|
|||||||
const EnvMaximumHeap = "LOTUS_MAX_HEAP"
|
const EnvMaximumHeap = "LOTUS_MAX_HEAP"
|
||||||
|
|
||||||
// ResourceConstraints represents resource constraints that Lotus and the go
|
// 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 {
|
var ResourceConstraints struct {
|
||||||
// MaxHeapMem is the maximum heap memory that has been set by the user
|
// 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
|
// through the LOTUS_MAX_HEAP env variable. If zero, there is no max heap
|
||||||
|
Loading…
Reference in New Issue
Block a user