Skip to content

Commit

Permalink
Alpha: Enable bloom filter caching (#5552)
Browse files Browse the repository at this point in the history
Badger supports the caching of SST bloom filters. This PR enables
caching bloom filters in ristretto. The bloom filter cache is enabled
only for the p directory. The bloom filters for the w directory will be
kept in memory. We can add caching for it later if necessary.

This PR also removes old stale todos.

(cherry picked from commit 92328a7)
  • Loading branch information
Ibrahim Jarif committed Jun 1, 2020
1 parent 06b04af commit a06415f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions dgraph/cmd/debug/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,8 @@ func run() {
}
bopts := badger.DefaultOptions(dir).
WithTableLoadingMode(options.MemoryMap).
WithReadOnly(opt.readOnly).WithEncryptionKey(enc.ReadEncryptionKeyFile(opt.badgerKeyFile))

// TODO(Ibrahim): Remove this once badger is updated.
bopts.ZSTDCompressionLevel = 1
WithReadOnly(opt.readOnly).
WithEncryptionKey(enc.ReadEncryptionKeyFile(opt.badgerKeyFile))

x.AssertTruef(len(bopts.Dir) > 0, "No posting or wal dir specified.")
fmt.Printf("Opening DB: %s\n", bopts.Dir)
Expand Down
3 changes: 1 addition & 2 deletions testutil/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ var KeyFile string

func openDgraph(pdir string) (*badger.DB, error) {
opt := badger.DefaultOptions(pdir).WithTableLoadingMode(options.MemoryMap).
// TOOD(Ibrahim): Remove compression level once badger is updated.
WithReadOnly(true).WithZSTDCompressionLevel(1).
WithReadOnly(true).
WithEncryptionKey(enc.ReadEncryptionKeyFile(KeyFile))
return badger.OpenManaged(opt)
}
Expand Down
3 changes: 2 additions & 1 deletion worker/server_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ func (s *ServerState) initStorage() {
WithNumVersionsToKeep(math.MaxInt32).
WithMaxCacheSize(1 << 30).
WithKeepBlockIndicesInCache(true).
WithKeepBlocksInCache(true)
WithKeepBlocksInCache(true).
WithMaxBfCacheSize(500 << 20) // 500 MB of bloom filter cache.
opt = setBadgerOptions(opt)

// Print the options w/o exposing key.
Expand Down

0 comments on commit a06415f

Please sign in to comment.