set all pebble DB's to 2k handles, set process RLimit
This commit is contained in:
parent
eb165fb359
commit
d884f96553
8 changed files with 33 additions and 10 deletions
|
@ -16,7 +16,7 @@ type Pebble struct {
|
||||||
|
|
||||||
func NewPebble(path string) (*Pebble, error) {
|
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}
|
repo := &Pebble{db: db}
|
||||||
|
|
||||||
return repo, errors.Wrapf(err, "unable to open %s", path)
|
return repo, errors.Wrapf(err, "unable to open %s", path)
|
||||||
|
|
|
@ -17,7 +17,7 @@ type Pebble struct {
|
||||||
|
|
||||||
func NewPebble(path string) (*Pebble, error) {
|
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}
|
repo := &Pebble{db: db}
|
||||||
|
|
||||||
return repo, errors.Wrapf(err, "open %s", path)
|
return repo, errors.Wrapf(err, "open %s", path)
|
||||||
|
|
|
@ -2,11 +2,33 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/lbryio/lbcd/claimtrie/param"
|
"github.com/lbryio/lbcd/claimtrie/param"
|
||||||
btcutil "github.com/lbryio/lbcutil"
|
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{
|
var DefaultConfig = Config{
|
||||||
Params: param.MainNet,
|
Params: param.MainNet,
|
||||||
|
|
||||||
|
|
|
@ -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}
|
repo := &Pebble{db: db}
|
||||||
|
|
||||||
return repo, errors.Wrapf(err, "unable to open %s", path)
|
return repo, errors.Wrapf(err, "unable to open %s", path)
|
||||||
|
|
|
@ -15,7 +15,7 @@ type Pebble struct {
|
||||||
|
|
||||||
func NewPebble(path string) (*Pebble, error) {
|
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}
|
repo := &Pebble{db: db}
|
||||||
|
|
||||||
return repo, errors.Wrapf(err, "unable to open %s", path)
|
return repo, errors.Wrapf(err, "unable to open %s", path)
|
||||||
|
|
|
@ -15,7 +15,7 @@ type Pebble struct {
|
||||||
|
|
||||||
func NewPebble(path string) (*Pebble, error) {
|
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}
|
repo := &Pebble{db: db}
|
||||||
|
|
||||||
return repo, errors.Wrapf(err, "unable to open %s", path)
|
return repo, errors.Wrapf(err, "unable to open %s", path)
|
||||||
|
|
|
@ -37,7 +37,7 @@ const (
|
||||||
// maxOpenFiles is the max number of open files to maintain in the
|
// maxOpenFiles is the max number of open files to maintain in the
|
||||||
// open blocks cache. Note that this does not include the current
|
// open blocks cache. Note that this does not include the current
|
||||||
// write file, so there will typically be one more than this value open.
|
// 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
|
// maxBlockFileSize is the maximum size for each file used to store
|
||||||
// blocks.
|
// blocks.
|
||||||
|
|
|
@ -2001,10 +2001,11 @@ func openDB(dbPath string, network wire.BitcoinNet, create bool) (database.DB, e
|
||||||
|
|
||||||
// Open the metadata database (will create it if needed).
|
// Open the metadata database (will create it if needed).
|
||||||
opts := opt.Options{
|
opts := opt.Options{
|
||||||
ErrorIfExist: create,
|
ErrorIfExist: create,
|
||||||
Strict: opt.DefaultStrict,
|
Strict: opt.DefaultStrict,
|
||||||
Compression: opt.NoCompression,
|
Compression: opt.NoCompression,
|
||||||
Filter: filter.NewBloomFilter(10),
|
Filter: filter.NewBloomFilter(10),
|
||||||
|
OpenFilesCacheCapacity: 2000,
|
||||||
}
|
}
|
||||||
ldb, err := leveldb.OpenFile(metadataDbPath, &opts)
|
ldb, err := leveldb.OpenFile(metadataDbPath, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue