Skip to content

Commit

Permalink
add pebble layers extra options
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Apr 23, 2024
1 parent 9e62e65 commit d6428a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ethdb/pebble/extraoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ExtraOptions struct {
WALMinSyncInterval func() time.Duration
TargetByteDeletionRate int
Experimental ExtraOptionsExperimental
Levels []ExtraLevelOptions
}

type ExtraOptionsExperimental struct {
Expand All @@ -25,3 +26,7 @@ type ExtraOptionsExperimental struct {
MaxWriterConcurrency int
ForceWriterParallelism bool
}

type ExtraLevelOptions struct {
TargetFileSize int64
}
27 changes: 17 additions & 10 deletions ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,22 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e
if extraOptions.MaxConcurrentCompactions == nil {
extraOptions.MaxConcurrentCompactions = func() int { return runtime.NumCPU() }
}

var levels []pebble.LevelOptions
if len(extraOptions.Levels) == 0 {
levels = []pebble.LevelOptions{
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
}
} else {
for _, level := range extraOptions.Levels {
levels = append(levels, pebble.LevelOptions{TargetFileSize: level.TargetFileSize, FilterPolicy: bloom.FilterPolicy(10)})
}
}
opt := &pebble.Options{
// Pebble has a single combined cache area and the write
// buffers are taken from this too. Assign all available
Expand All @@ -216,15 +231,7 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e

// Per-level extraOptions. Options for at least one level must be specified. The
// extraOptions for the last level are used for all subsequent levels.
Levels: []pebble.LevelOptions{
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
},
Levels: levels,
ReadOnly: readonly,
EventListener: &pebble.EventListener{
CompactionBegin: db.onCompactionBegin,
Expand Down

0 comments on commit d6428a6

Please sign in to comment.