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

feat(flags): [Breaking] Add cache superflag for alpha #7652

Merged
merged 5 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
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
27 changes: 14 additions & 13 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ they form a Raft group and provide synchronous replication.
// --encryption_key_file
enc.RegisterFlags(flag)

flag.String("cache_percentage", "0,65,35,0",
`Cache percentages summing up to 100 for various caches (FORMAT: PostingListCache,`+
`PstoreBlockCache,PstoreIndexCache,WAL).`)

flag.StringP("postings", "p", "p", "Directory to store posting lists.")
flag.String("tmp", "t", "Directory to store temporary buffers.")

Expand Down Expand Up @@ -149,6 +145,16 @@ they form a Raft group and provide synchronous replication.
"worker in a failed state. Use -1 to retry infinitely.").
String())

// Cache flags.
flag.String("cache", worker.CacheDefaults, z.NewSuperFlagHelp(worker.CacheDefaults).
Head("Cache options").
Flag("size-mb",
"Total size of cache (in MB) to be used in Dgraph.").
Flag("percentage",
"Cache percentages summing up to 100 for various caches (FORMAT: PostingListCache,"+
"PstoreBlockCache,PstoreIndexCache,WAL)").
Copy link
Contributor

@jarifibrahim jarifibrahim Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed. The pstoreblock cache and pstore index cache values are being fetched from the badger super flag. We don't need them over here.

Also, the wal is no longer supported.
@NamanJain8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the wal cache from flag. Also, we decided to keep the cache as it is.

String())

flag.String("raft", worker.RaftDefaults, z.NewSuperFlagHelp(worker.RaftDefaults).
Head("Raft options").
Flag("idx",
Expand Down Expand Up @@ -614,17 +620,12 @@ func run() {
}

bindall = Alpha.Conf.GetBool("bindall")

totalCache := int64(Alpha.Conf.GetInt("cache_mb"))
cache := z.NewSuperFlag(Alpha.Conf.GetString("cache")).MergeAndCheckDefault(
worker.CacheDefaults)
totalCache := cache.GetInt64("size-mb")
x.AssertTruef(totalCache >= 0, "ERROR: Cache size must be non-negative")
if Alpha.Conf.IsSet("lru_mb") {
rohanprasad marked this conversation as resolved.
Show resolved Hide resolved
glog.Warningln("--lru_mb is deprecated, use --cache_mb instead")
if !Alpha.Conf.IsSet("cache_mb") {
totalCache = int64(Alpha.Conf.GetFloat64("lru_mb"))
}
}

cachePercentage := Alpha.Conf.GetString("cache_percentage")
cachePercentage := cache.GetString("percentage")
cachePercent, err := x.GetCachePercentages(cachePercentage, 4)
x.Check(err)
postingListCacheSize := (cachePercent[0] * (totalCache << 20)) / 100
Expand Down
3 changes: 3 additions & 0 deletions dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ instances to achieve high-availability.
// --tls SuperFlag
x.RegisterServerTLSFlags(flag)

// Cache flags.
flag.Int64("cache_mb", 1024, "Total size of cache (in MB) to be used in Dgraph.")
rohanprasad marked this conversation as resolved.
Show resolved Hide resolved

flag.IntP("port_offset", "o", 0,
"Value added to all listening port numbers. [Grpc=5080, HTTP=6080]")
flag.Int("replicas", 1, "How many Dgraph Alpha replicas to run per data shard group."+
Expand Down
1 change: 1 addition & 0 deletions worker/server_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
`mutations-nquad=1000000; disallow-drop=false; query-timeout=0ms;`
GraphQLDefaults = `introspection=true; debug=false; extensions=true; poll-interval=1s; ` +
`lambda-url=;`
CacheDefaults = `size-mb=1024; percentage=0,65,35,0;`
)

// ServerState holds the state of the Dgraph server.
Expand Down
3 changes: 0 additions & 3 deletions x/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ func FillCommonFlags(flag *pflag.FlagSet) {
`guaranteeing no data loss in case of hard reboot.`+"\n "+
`Most users should be OK with choosing "process".`)

// Cache flags.
flag.Int64("cache_mb", 1024, "Total size of cache (in MB) to be used in Dgraph.")

flag.String("telemetry", TelemetryDefaults, z.NewSuperFlagHelp(TelemetryDefaults).
Head("Telemetry (diagnostic) options").
Flag("reports",
Expand Down