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

[BREAKING/cli-flags] feat(bulk): Use snappy compression by default. #6697

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions dgraph/cmd/bulk/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"time"

"github.com/dgraph-io/badger/v2"
bo "github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/y"

"github.com/dgraph-io/dgraph/chunker"
Expand Down Expand Up @@ -77,6 +78,8 @@ type options struct {
// ........... Badger options ..........
// EncryptionKey is the key used for encryption. Enterprise only feature.
EncryptionKey x.SensitiveByteSlice
// BadgerCompression is the compression algorithm to use while writing to badger.
BadgerCompression bo.CompressionType
// BadgerCompressionlevel is the compression level to use while writing to badger.
BadgerCompressionLevel int
BlockCacheSize int64
Expand Down
2 changes: 1 addition & 1 deletion dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (r *reducer) createBadgerInternal(dir string, compression bool) *badger.DB
opt.ZSTDCompressionLevel = 0
// Overwrite badger options based on the options provided by the user.
if compression {
opt.Compression = bo.ZSTD
opt.Compression = r.state.opt.BadgerCompression
opt.ZSTDCompressionLevel = r.state.opt.BadgerCompressionLevel
}

Expand Down
10 changes: 7 additions & 3 deletions dgraph/cmd/bulk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ func init() {
"Ignore UIDs in load files and assign new ones.")

// Options around how to set up Badger.
flag.Int("badger.compression_level", 1,
"The compression level for Badger. A higher value uses more resources.")
flag.String("badger.compression", "snappy",
"[none, zstd:level, snappy] Specifies the compression algorithm and the compression"+
"level (if applicable) for the postings directory. none would disable compression,"+
" while zstd:1 would set zstd compression at level 1.")
flag.Int64("badger.cache_mb", 64, "Total size of cache (in MB) per shard in reducer.")
flag.String("badger.cache_percentage", "70,30",
"Cache percentages summing up to 100 for various caches"+
Expand All @@ -120,6 +122,7 @@ func init() {
}

func run() {
ctype, clevel := x.ParseCompression(Bulk.Conf.GetString("badger.compression"))
opt := options{
DataFiles: Bulk.Conf.GetString("files"),
DataFormat: Bulk.Conf.GetString("format"),
Expand Down Expand Up @@ -147,7 +150,8 @@ func run() {
NewUids: Bulk.Conf.GetBool("new_uids"),
ClientDir: Bulk.Conf.GetString("xidmap"),
// Badger options
BadgerCompressionLevel: Bulk.Conf.GetInt("badger.compression_level"),
BadgerCompression: ctype,
BadgerCompressionLevel: clevel,
}

x.PrintVersion()
Expand Down