Skip to content

Commit

Permalink
Merge pull request #191 from coinbase/patrick/badger-performance-mode
Browse files Browse the repository at this point in the history
[storage] Add Performance Mode Config
  • Loading branch information
patrick-ogrady authored Oct 15, 2020
2 parents 250f7d0 + 99f826b commit 234ed4b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions storage/badger_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,36 @@ func DefaultBadgerOptions(dir string) badger.Options {
return opts
}

// PerformanceBadgerOptions are performance geared
// BadgerDB options that use much more RAM than the
// default settings.
func PerformanceBadgerOptions(dir string) badger.Options {
opts := badger.DefaultOptions(dir)

// By default, we do not compress the table at all. Doing so can
// significantly increase memory usage.
opts.Compression = DefaultCompressionMode

// Load tables into memory and memory map value logs.
opts.TableLoadingMode = options.MemoryMap
opts.ValueLogLoadingMode = options.MemoryMap

// This option will have a significant effect the memory. If the level is kept
// in-memory, read are faster but the tables will be kept in memory. By default,
// this is set to false.
opts.KeepL0InMemory = false

// We don't compact L0 on close as this can greatly delay shutdown time.
opts.CompactL0OnClose = false

// LoadBloomsOnOpen=false will improve the db startup speed. This is also
// a waste to enable with a limited index cache size (as many of the loaded bloom
// filters will be immediately discarded from the cache).
opts.LoadBloomsOnOpen = false

return opts
}

// NewBadgerStorage creates a new BadgerStorage.
func NewBadgerStorage(
ctx context.Context,
Expand Down

0 comments on commit 234ed4b

Please sign in to comment.