channeldb + wtdb: specify freelist bbolt options by default

This commit specifies two bbolt options when opening the underlying
channel and watchtower databases so that there is reduced heap
pressure in case the bbolt database has a lot of free pages in the
B+ tree.
This commit is contained in:
nsa 2019-07-08 18:41:25 -04:00
parent 4fd78926d4
commit 66d15c8e76
2 changed files with 16 additions and 2 deletions

@ -135,7 +135,14 @@ func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
modifier(&opts) modifier(&opts)
} }
bdb, err := bbolt.Open(path, dbFilePermission, 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,
}
bdb, err := bbolt.Open(path, dbFilePermission, options)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -63,7 +63,14 @@ func createDBIfNotExist(dbPath, name string) (*bbolt.DB, bool, error) {
} }
} }
bdb, err := bbolt.Open(path, dbFilePermission, 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,
}
bdb, err := bbolt.Open(path, dbFilePermission, options)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
} }