From 44040f0f3faaa5b1783a37312c5ced4325c92e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Fri, 20 Nov 2020 00:33:43 +0000 Subject: [PATCH] badger options: enable IndexCache and CompactL0OnClose. --- node/repo/blockstore_opts.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node/repo/blockstore_opts.go b/node/repo/blockstore_opts.go index d8d852d84..6c2c9ee09 100644 --- a/node/repo/blockstore_opts.go +++ b/node/repo/blockstore_opts.go @@ -21,9 +21,8 @@ func BadgerBlockstoreOptions(domain BlockstoreDomain, path string, readonly bool opts.DetectConflicts = false // This is to optimize the database on close so it can be opened - // read-only and efficiently queried. We don't do that and hanging on - // stop isn't nice. - opts.CompactL0OnClose = false + // read-only and efficiently queried. + opts.CompactL0OnClose = true // The alternative is "crash on start and tell the user to fix it". This // will truncate corrupt and unsynced data, which we don't guarantee to @@ -42,6 +41,11 @@ 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 + // IndexCacheSize is 1GiB. 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. + opts.IndexCacheSize = 1 << 30 + // NOTE: The chain blockstore doesn't require any GC (blocks are never // deleted). This will change if we move to a tiered blockstore.