Skip to content

Commit

Permalink
Utilize pebbleDB options
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Dec 10, 2024
1 parent 926b485 commit dcb45a3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions db/pebble/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"context"
"errors"
"fmt"
"runtime"
"sync"
"testing"

"github.com/NethermindEth/juno/db"
"github.com/NethermindEth/juno/utils"
"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/bloom"
"github.com/cockroachdb/pebble/vfs"
)

Expand Down Expand Up @@ -46,9 +48,21 @@ func NewWithOptions(path string, cacheSizeMB uint, maxOpenFiles int, colouredLog
}

return newPebble(path, &pebble.Options{
Logger: dbLog,
Cache: pebble.NewCache(int64(cacheSizeMB * utils.Megabyte)),
MaxOpenFiles: maxOpenFiles,
Logger: dbLog,
Cache: pebble.NewCache(int64(cacheSizeMB * utils.Megabyte)),
MaxOpenFiles: maxOpenFiles,
MemTableSize: uint64(cacheSizeMB * utils.Megabyte / 2),
MemTableStopWritesThreshold: 2,
MaxConcurrentCompactions: runtime.NumCPU,
Levels: []pebble.LevelOptions{
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},

Check failure on line 58 in db/pebble/db.go

View workflow job for this annotation

GitHub Actions / lint

Magic number: 10, in <argument> detected (mnd)
{TargetFileSize: 4 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},

Check failure on line 59 in db/pebble/db.go

View workflow job for this annotation

GitHub Actions / lint

Magic number: 10, in <argument> detected (mnd)
{TargetFileSize: 8 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},

Check failure on line 60 in db/pebble/db.go

View workflow job for this annotation

GitHub Actions / lint

Magic number: 10, in <argument> detected (mnd)
{TargetFileSize: 16 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 32 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 64 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 128 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
},
})
}

Expand Down

0 comments on commit dcb45a3

Please sign in to comment.