set all pebble DB's to 2k handles, set process RLimit

This commit is contained in:
Brannon King 2021-09-24 13:25:27 -04:00 committed by Roy Lee
parent eb165fb359
commit d884f96553
8 changed files with 33 additions and 10 deletions

View file

@ -16,7 +16,7 @@ type Pebble struct {
func NewPebble(path string) (*Pebble, error) {
db, err := pebble.Open(path, nil)
db, err := pebble.Open(path, &pebble.Options{MaxOpenFiles: 2000})
repo := &Pebble{db: db}
return repo, errors.Wrapf(err, "unable to open %s", path)

View file

@ -17,7 +17,7 @@ type Pebble struct {
func NewPebble(path string) (*Pebble, error) {
db, err := pebble.Open(path, &pebble.Options{BytesPerSync: 64 << 20})
db, err := pebble.Open(path, &pebble.Options{BytesPerSync: 64 << 20, MaxOpenFiles: 2000})
repo := &Pebble{db: db}
return repo, errors.Wrapf(err, "open %s", path)

View file

@ -2,11 +2,33 @@ package config
import (
"path/filepath"
"syscall"
"github.com/lbryio/lbcd/claimtrie/param"
btcutil "github.com/lbryio/lbcutil"
)
func init() {
// ensure that we have enough file handles
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
panic("Error getting File Handle RLimit: " + err.Error())
}
minRequiredFileHandles := uint64(24000) // seven databases and they each require ~2000, plus a few more to be safe
if rLimit.Max < minRequiredFileHandles {
panic("Error increasing File Handle RLimit: increasing file handle limit requires " +
"unavailable privileges. Allow at least 24000 handles.")
}
if rLimit.Cur < minRequiredFileHandles {
rLimit.Cur = minRequiredFileHandles
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
panic("Error setting File Handle RLimit to 24000: " + err.Error())
}
}
}
var DefaultConfig = Config{
Params: param.MainNet,

View file

@ -31,7 +31,7 @@ func NewPebble(path string) (*Pebble, error) {
// }
//}()
db, err := pebble.Open(path, &pebble.Options{Cache: cache, BytesPerSync: 32 << 20})
db, err := pebble.Open(path, &pebble.Options{Cache: cache, BytesPerSync: 32 << 20, MaxOpenFiles: 2000})
repo := &Pebble{db: db}
return repo, errors.Wrapf(err, "unable to open %s", path)

View file

@ -15,7 +15,7 @@ type Pebble struct {
func NewPebble(path string) (*Pebble, error) {
db, err := pebble.Open(path, &pebble.Options{Cache: pebble.NewCache(64 << 20), BytesPerSync: 4 << 20})
db, err := pebble.Open(path, &pebble.Options{Cache: pebble.NewCache(64 << 20), BytesPerSync: 8 << 20, MaxOpenFiles: 2000})
repo := &Pebble{db: db}
return repo, errors.Wrapf(err, "unable to open %s", path)

View file

@ -15,7 +15,7 @@ type Pebble struct {
func NewPebble(path string) (*Pebble, error) {
db, err := pebble.Open(path, &pebble.Options{Cache: pebble.NewCache(16 << 20)})
db, err := pebble.Open(path, &pebble.Options{Cache: pebble.NewCache(16 << 20), MaxOpenFiles: 2000})
repo := &Pebble{db: db}
return repo, errors.Wrapf(err, "unable to open %s", path)

View file

@ -37,7 +37,7 @@ const (
// maxOpenFiles is the max number of open files to maintain in the
// open blocks cache. Note that this does not include the current
// write file, so there will typically be one more than this value open.
maxOpenFiles = 25
maxOpenFiles = 40
// maxBlockFileSize is the maximum size for each file used to store
// blocks.

View file

@ -2005,6 +2005,7 @@ func openDB(dbPath string, network wire.BitcoinNet, create bool) (database.DB, e
Strict: opt.DefaultStrict,
Compression: opt.NoCompression,
Filter: filter.NewBloomFilter(10),
OpenFilesCacheCapacity: 2000,
}
ldb, err := leveldb.OpenFile(metadataDbPath, &opts)
if err != nil {