From d8ec5c6c8b45f58f4a5a9a327ad362b8fe9870f8 Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Mon, 1 Jun 2020 14:43:21 +0530 Subject: [PATCH] Alpha: Enable bloom filter caching Badger supports caching of SST bloom filters, this PR enables caching bloom filters in ristretto. --- dgraph/cmd/debug/run.go | 6 ++---- testutil/backup.go | 3 +-- worker/server_state.go | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dgraph/cmd/debug/run.go b/dgraph/cmd/debug/run.go index 4ca9bc3aff0..f20eeeb1245 100644 --- a/dgraph/cmd/debug/run.go +++ b/dgraph/cmd/debug/run.go @@ -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) diff --git a/testutil/backup.go b/testutil/backup.go index 217aeec09dc..b5573d73a95 100644 --- a/testutil/backup.go +++ b/testutil/backup.go @@ -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) } diff --git a/worker/server_state.go b/worker/server_state.go index 5e2fcb1fb51..adc89727d21 100644 --- a/worker/server_state.go +++ b/worker/server_state.go @@ -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.