From e809748b1e5563ef90ec04246762e7b67f283706 Mon Sep 17 00:00:00 2001 From: nsa Date: Thu, 1 Aug 2019 22:15:53 -0400 Subject: [PATCH] bdb: specify freelist options by default This commit specifies two bbolt options when opening the bbolt db. This reduces heap pressure in case there are a lot of pages on the freelist. --- walletdb/bdb/db.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/walletdb/bdb/db.go b/walletdb/bdb/db.go index bf34e7a..ab611ba 100644 --- a/walletdb/bdb/db.go +++ b/walletdb/bdb/db.go @@ -344,6 +344,13 @@ func openDB(dbPath string, create bool) (walletdb.DB, error) { return nil, walletdb.ErrDbDoesNotExist } - boltDB, err := bbolt.Open(dbPath, 0600, nil) + // Specify bbolt freelist options to reduce heap pressure in case the + // freelist grows to be very large. + options := &bbolt.Options{ + NoFreelistSync: true, + FreelistType: bbolt.FreelistMapType, + } + + boltDB, err := bbolt.Open(dbPath, 0600, options) return (*db)(boltDB), convertErr(err) }