diff --git a/ethdb/pebble/extraoptions.go b/ethdb/pebble/extraoptions.go index cafc809e6b..7fdea8dbcb 100644 --- a/ethdb/pebble/extraoptions.go +++ b/ethdb/pebble/extraoptions.go @@ -15,6 +15,7 @@ type ExtraOptions struct { WALMinSyncInterval func() time.Duration TargetByteDeletionRate int Experimental ExtraOptionsExperimental + Levels []ExtraLevelOptions } type ExtraOptionsExperimental struct { @@ -25,3 +26,7 @@ type ExtraOptionsExperimental struct { MaxWriterConcurrency int ForceWriterParallelism bool } + +type ExtraLevelOptions struct { + TargetFileSize int64 +} diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index 2ac400d32f..662a739039 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -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 @@ -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,