Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions kvdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync/atomic"

"github.com/cockroachdb/pebble/v2"
"github.com/cockroachdb/pebble/v2/bloom"
"github.com/cockroachdb/pebble/v2/vfs"
"github.com/google/uuid"
)
Expand Down Expand Up @@ -38,15 +39,27 @@ func NewKV[T Evaluable](o KVOpts[T]) (KV[T], error) {
o.FS = vfs.Default
}

db, err := pebble.Open(o.Dir, &pebble.Options{
FS: o.FS,
// cockroachdb defaults that should slightly help with faster writes
// https://github.com/cockroachdb/cockroach/blob/5a1f5da5bb3b2d962d8737848a4fca69f915dacb/pkg/storage/pebble.go#L668-L673
L0CompactionThreshold: 2,
// closely following some of cockroachdb defaults
// https://github.com/cockroachdb/cockroach/blob/5a1f5da5bb3b2d962d8737848a4fca69f915dacb/pkg/storage/pebble.go#L668-L673
opts := &pebble.Options{
FS: o.FS,
Cache: pebble.NewCache(512 << 20),
DisableWAL: true,
L0CompactionThreshold: 8,
L0StopWritesThreshold: 1000,
MemTableSize: 64 << 20, // 64 MB
MemTableStopWritesThreshold: 4,
})
CompactionConcurrencyRange: func() (int, int) { return 1, 4 },
}
opts.Levels[0] = pebble.LevelOptions{
BlockSize: 32 << 10,
IndexBlockSize: 256 << 10,
FilterPolicy: bloom.FilterPolicy(10),
FilterType: pebble.TableFilter,
}
opts.Levels[0].EnsureL0Defaults()

db, err := pebble.Open(o.Dir, opts)
if err != nil {
return nil, err
}
Expand Down
Loading