Skip to content

Commit

Permalink
cli/start: also warn when --max-sql-memory is not set
Browse files Browse the repository at this point in the history
Prior to this patch, a warning was reported if the user
was running `cockroach` with the `--cache` parameter left
to its default value.

Such a warning is also useful for `--max-sql-memory`.
This patch adds it.

Release note: None
  • Loading branch information
knz committed Jan 9, 2018
1 parent b658aa7 commit 115b477
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,21 +763,33 @@ func reportConfiguration(ctx context.Context) {
}
}

func maybeWarnCacheSize() {
if cacheSizeValue.IsSet() {
return
func maybeWarnMemorySizes(ctx context.Context) {
// Is the cache configuration OK?
if !cacheSizeValue.IsSet() {
var buf bytes.Buffer
fmt.Fprintf(&buf, "Using the default setting for --cache (%s).\n", cacheSizeValue)
fmt.Fprintf(&buf, " A significantly larger value is usually needed for good performance.\n")
if size, err := server.GetTotalMemory(context.Background()); err == nil {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is --cache=25%% (%s).",
humanizeutil.IBytes(size/4))
} else {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is 25%% of physical memory.")
}
log.Warning(ctx, buf.String())
}

var buf bytes.Buffer
fmt.Fprintf(&buf, "Using the default setting for --cache (%s).\n", cacheSizeValue)
fmt.Fprintf(&buf, " A significantly larger value is usually needed for good performance.\n")
if size, err := server.GetTotalMemory(context.Background()); err == nil {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is --cache=25%% (%s).",
humanizeutil.IBytes(size/4))
} else {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is 25%% of physical memory.")
if !sqlSizeValue.IsSet() {
var buf bytes.Buffer
fmt.Fprintf(&buf, "Using the default setting for --max-sql-memory (%s).\n", sqlSizeValue)
fmt.Fprintf(&buf, " A significantly larger value is usually needed in production.\n")
if size, err := server.GetTotalMemory(context.Background()); err == nil {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is --max-sql-memory=25%% (%s).",
humanizeutil.IBytes(size/4))
} else {
fmt.Fprintf(&buf, " If you have a dedicated server a reasonable setting is 25%% of physical memory.")
}
log.Warning(ctx, buf.String())
}
log.Warning(context.Background(), buf.String())
}

// setupAndInitializeLoggingAndProfiling does what it says on the label.
Expand Down Expand Up @@ -860,7 +872,7 @@ func setupAndInitializeLoggingAndProfiling(ctx context.Context) (*stop.Stopper,
"Check out how to secure your cluster: "+base.DocsURL("secure-a-cluster.html"))
}

maybeWarnCacheSize()
maybeWarnMemorySizes(ctx)

// We log build information to stdout (for the short summary), but also
// to stderr to coincide with the full logs.
Expand Down

0 comments on commit 115b477

Please sign in to comment.