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.
This commit is contained in:
nsa 2019-08-01 22:15:53 -04:00
parent 604661be3d
commit e809748b1e

View file

@ -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)
}