Skip to content

Commit d6428a6

Browse files
committed
add pebble layers extra options
1 parent 9e62e65 commit d6428a6

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

ethdb/pebble/extraoptions.go

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type ExtraOptions struct {
1515
WALMinSyncInterval func() time.Duration
1616
TargetByteDeletionRate int
1717
Experimental ExtraOptionsExperimental
18+
Levels []ExtraLevelOptions
1819
}
1920

2021
type ExtraOptionsExperimental struct {
@@ -25,3 +26,7 @@ type ExtraOptionsExperimental struct {
2526
MaxWriterConcurrency int
2627
ForceWriterParallelism bool
2728
}
29+
30+
type ExtraLevelOptions struct {
31+
TargetFileSize int64
32+
}

ethdb/pebble/pebble.go

+17-10
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,22 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e
191191
if extraOptions.MaxConcurrentCompactions == nil {
192192
extraOptions.MaxConcurrentCompactions = func() int { return runtime.NumCPU() }
193193
}
194-
194+
var levels []pebble.LevelOptions
195+
if len(extraOptions.Levels) == 0 {
196+
levels = []pebble.LevelOptions{
197+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
198+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
199+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
200+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
201+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
202+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
203+
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
204+
}
205+
} else {
206+
for _, level := range extraOptions.Levels {
207+
levels = append(levels, pebble.LevelOptions{TargetFileSize: level.TargetFileSize, FilterPolicy: bloom.FilterPolicy(10)})
208+
}
209+
}
195210
opt := &pebble.Options{
196211
// Pebble has a single combined cache area and the write
197212
// 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
216231

217232
// Per-level extraOptions. Options for at least one level must be specified. The
218233
// extraOptions for the last level are used for all subsequent levels.
219-
Levels: []pebble.LevelOptions{
220-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
221-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
222-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
223-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
224-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
225-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
226-
{TargetFileSize: 2 * 1024 * 1024, FilterPolicy: bloom.FilterPolicy(10)},
227-
},
234+
Levels: levels,
228235
ReadOnly: readonly,
229236
EventListener: &pebble.EventListener{
230237
CompactionBegin: db.onCompactionBegin,

0 commit comments

Comments
 (0)