Skip to content

Commit

Permalink
change default settings for the database, to allow for effective garb…
Browse files Browse the repository at this point in the history
…age collection

fixes ipfs#54

settings are by courtesy of @jsign, see [his post here](dgraph-io/badger#1297 (comment))
  • Loading branch information
RubenKelevra authored May 29, 2020
1 parent a69f102 commit 08e404a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,25 @@ var DefaultOptions Options

func init() {
DefaultOptions = Options{
GcDiscardRatio: 0.2,
GcDiscardRatio: 0.01,
GcInterval: 15 * time.Minute,
GcSleep: 10 * time.Second,
Options: badger.LSMOnlyOptions(""),
}
// This is to optimize the database on close so it can be opened
// read-only and efficiently queried. We don't do that and hanging on
// stop isn't nice.
DefaultOptions.Options.CompactL0OnClose = false
// This is to optimize the database on closure
DefaultOptions.Options.CompactL0OnClose = true

// Remove elements which the has been deleted from the database
DefaultOptions.Options.NumVersionsToKeep = 0

// Reduce the number of zero tables (which are hold in memory)
DefaultOptions.Options.NumLevelZeroTables = 1

// Reduce the number of zero tables which are stalled
DefaultOptions.Options.NumLevelZeroTablesStall = 2

// Reduce the max vlog size usage after compaction (
DefaultOptions.Options.ValueLogFileSize = 10485760

// The alternative is "crash on start and tell the user to fix it". This
// will truncate corrupt and unsynced data, which we don't guarantee to
Expand Down

0 comments on commit 08e404a

Please sign in to comment.