fix GolevelDB perfomance degradation issue

by increasing cache and write buffer size
also, bloom filter is used to speed up lookups

Refs #1835
This commit is contained in:
Anton Kaliaev 2018-09-12 13:13:32 +04:00
parent ec8f1b7ee3
commit e164278b63
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 7 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/filter"
"github.com/syndtr/goleveldb/leveldb/iterator"
"github.com/syndtr/goleveldb/leveldb/opt"
@ -23,12 +24,17 @@ func init() {
var _ DB = (*GoLevelDB)(nil)
var defaultOptions = &opt.Options{OpenFilesCacheCapacity: 1024,
BlockCacheCapacity: 768 / 2 * opt.MiB,
WriteBuffer: 768 / 4 * opt.MiB, // Two of these are used internally
Filter: filter.NewBloomFilter(10)}
type GoLevelDB struct {
db *leveldb.DB
}
func NewGoLevelDB(name string, dir string) (*GoLevelDB, error) {
return NewGoLevelDBWithOpts(name, dir, nil)
return NewGoLevelDBWithOpts(name, dir, defaultOptions)
}
func NewGoLevelDBWithOpts(name string, dir string, o *opt.Options) (*GoLevelDB, error) {