Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Dgraph): Add flags to set table and vlog loading mode for zero. #6315

Merged
merged 3 commits into from
Aug 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"google.golang.org/grpc"

"github.com/dgraph-io/badger/v2"
bopt "github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/dgraph/conn"
"github.com/dgraph-io/dgraph/ee/enc"
Expand Down Expand Up @@ -108,6 +109,15 @@ instances to achieve high-availability.
flag.Int64("cache_mb", 0, "Total size of cache (in MB) to be used in zero.")
flag.String("cache_percentage", "100,0",
"Cache percentages summing up to 100 for various caches (FORMAT: blockCache,indexCache).")

// Badger flags
flag.String("badger.tables", "mmap",
"[ram, mmap, disk] Specifies how Badger LSM tree is stored for write-ahead log directory "+
"write-ahead directory. Option sequence consume most to least RAM while providing "+
"best to worst read performance respectively")
flag.String("badger.vlog", "mmap",
"[mmap, disk] Specifies how Badger Value log is stored for the write-ahead log directory "+
"log directory. mmap consumes more RAM, but provides better performance.")
}

func setupListener(addr string, port int, kind string) (listener net.Listener, err error) {
Expand Down Expand Up @@ -260,6 +270,27 @@ func run() {

kvOpt.ZSTDCompressionLevel = 3

// Set loading mode options.
switch Zero.Conf.GetString("badger.tables") {
case "mmap":
kvOpt.TableLoadingMode = bopt.MemoryMap
case "ram":
kvOpt.TableLoadingMode = bopt.LoadToRAM
case "disk":
kvOpt.TableLoadingMode = bopt.FileIO
default:
x.Fatalf("Invalid Badger Tables options")
}
switch Zero.Conf.GetString("badger.vlog") {
case "mmap":
kvOpt.ValueLogLoadingMode = bopt.MemoryMap
case "disk":
kvOpt.ValueLogLoadingMode = bopt.FileIO
default:
x.Fatalf("Invalid Badger Value log options")
}
glog.Infof("Opening WAL store BadgerDB with options: %+v\n", kvOpt)
martinmr marked this conversation as resolved.
Show resolved Hide resolved

kv, err := badger.Open(kvOpt)
x.Checkf(err, "Error while opening WAL store")
defer kv.Close()
Expand Down