From a9eaa8132b356593a06600d6081e34218edf671c Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Tue, 1 Sep 2020 10:50:59 -0700 Subject: [PATCH] (release/v20.03) fix(Dgraph): add flag to set up compression in zero. (cherry picked from commit 254bd2904fa236ef4527d8744f2246af27b61d9a) --- dgraph/cmd/zero/run.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go index 5fb2f745794..763aec33ce0 100644 --- a/dgraph/cmd/zero/run.go +++ b/dgraph/cmd/zero/run.go @@ -113,6 +113,8 @@ instances to achieve high-availability. 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.") + 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) { @@ -248,7 +250,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 + } // Set loading mode options. switch Zero.Conf.GetString("badger.tables") {