Skip to content

Commit

Permalink
Merge pull request #336 from qianbin/optimize-db-compaction
Browse files Browse the repository at this point in the history
Optimize leveldb compaction
  • Loading branch information
qianbin authored Feb 26, 2020
2 parents 5429547 + 141d1c8 commit 272f9ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ require (
gopkg.in/yaml.v2 v2.2.2
)

replace github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d => github.com/qianbin/goleveldb v1.0.1-0.20191124163202-7356cd382be0
replace github.com/syndtr/goleveldb => github.com/qianbin/goleveldb v1.0.1-0.20200224175121-b3d3749bde47
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qianbin/goleveldb v1.0.1-0.20191124163202-7356cd382be0 h1:LBric59taAOVLkgtodOfGMuUcxQIOQKe70IhLBIgbCg=
github.com/qianbin/goleveldb v1.0.1-0.20191124163202-7356cd382be0/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
github.com/qianbin/goleveldb v1.0.1-0.20200224175121-b3d3749bde47 h1:R0Cywm0bLDDOmg/mvzDGaxCtWnkuRfDxysTaMz5a1Qo=
github.com/qianbin/goleveldb v1.0.1-0.20200224175121-b3d3749bde47/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
Expand Down
16 changes: 9 additions & 7 deletions muxdb/muxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
package muxdb

import (
"io"

"github.com/syndtr/goleveldb/leveldb"
dberrors "github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/filter"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/storage"
"github.com/vechain/thor/kv"
"github.com/vechain/thor/thor"
"io"
)

const (
Expand Down Expand Up @@ -62,12 +63,13 @@ type MuxDB struct {
func Open(path string, options *Options) (*MuxDB, error) {
// prepare leveldb options
ldbOpts := opt.Options{
OpenFilesCacheCapacity: options.OpenFilesCacheCapacity,
BlockCacheCapacity: options.ReadCacheMB * opt.MiB,
WriteBuffer: options.WriteBufferMB * opt.MiB,
Filter: filter.NewBloomFilter(10),
BlockSize: 1024 * 32, // balance performance of point reads and compression ratio.
DisableSeeksCompaction: true,
OpenFilesCacheCapacity: options.OpenFilesCacheCapacity,
BlockCacheCapacity: options.ReadCacheMB * opt.MiB,
WriteBuffer: options.WriteBufferMB * opt.MiB,
Filter: filter.NewBloomFilter(10),
BlockSize: 1024 * 32, // balance performance of point reads and compression ratio.
DisableSeeksCompaction: true,
CompactionTableSizeMultiplier: 2,
KeyVolatile: func(key []byte) bool {
switch key[0] {
case trieSpaceA, trieSpaceB, trieSecureKeySpace:
Expand Down

0 comments on commit 272f9ed

Please sign in to comment.