From 68ed49d0ea10d7a22a701413f0949e7d1e55dabf Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Mon, 31 Aug 2020 12:19:47 -0700 Subject: [PATCH] fix(Dgraph): add flag to set up compression in zero. --- dgraph/cmd/zero/run.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go index 0a77e088168..a1b8e82c0db 100644 --- a/dgraph/cmd/zero/run.go +++ b/dgraph/cmd/zero/run.go @@ -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" @@ -108,6 +109,9 @@ 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).") + + flag.Int("badger.compression_level", 3, + "The compression level for Badger. A higher value uses more resources.") } func setupListener(addr string, port int, kind string) (listener net.Listener, err error) { @@ -258,7 +262,12 @@ func run() { WithIndexCacheSize(indexCacheSz). WithLoadBloomsOnOpen(false) - kvOpt.ZSTDCompressionLevel = 3 + compression_level := Zero.Conf.GetInt("badger.compression_level") + if compression_level > 0 { + // By default, compression is disabled in badger. + kvOpt.Compression = bopt.ZSTD + kvOpt.ZSTDCompressionLevel = compression_level + } kv, err := badger.Open(kvOpt) x.Checkf(err, "Error while opening WAL store")