Skip to content

Commit

Permalink
Alpha: Enable bloom filter caching (dgraph-io#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.
  • Loading branch information
Ibrahim Jarif authored and dna2github committed Jul 18, 2020
1 parent a9f7129 commit a05f236
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.keyFile))

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

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 @@ -153,7 +153,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 a05f236

Please sign in to comment.