Description
Exalate commented:
Related PR: cockroachdb/cockroach#97666
Commit: cockroachdb/cockroach@2e6ae80
Fixes: cockroachdb/cockroach#95690
Release note (cli change): New flag --max-go-memory
is introduced to
start
command. It controls the soft memory limit on the Go runtime
which adjusts the behavior of the Go garbage collector to try keeping the
memory usage under the soft memory limit (the limit is "soft" in a sense
that it is not enforced if live objects (RSS) exceed it). Similar to the
--max-sql-memory
flag, the new flag --max-go-memory
accepts numbers
interpreted as bytes, size suffixes (e.g. 1GB and 1GiB) or a percentage
of physical memory (e.g. .25). If left unspecified, the flag defaults to
2.25x of --max-sql-memory
(subject to --max-go-memory + 1.15x --cache
not exceeding 90% of available RAM). Set to 0 to disable the soft memory
limit (not recommended). If GOMEMLIMIT env var is set and
--max-go-memory
is not, then the value from the env var is used; if
both are set, then the flag takes precedence.
Here is a few examples of how the default value is calculated on
a machine with 16GiB of RAM:
Command line flags | Computed max SQL memory | Computed cache size | Computed max Go memory |
---|---|---|---|
--max-sql-memory=.25 --cache=.25 | 4GiB | 4GiB | 9GiB |
--max-sql-memory=.1 --cache=.5 | 1.6GiB | 8GiB | 3.6GiB |
--max-sql-memory=.25 --cache=.4 | 4GiB | 6.4GiB | 7.04GiB |
--max-sql-memory=100MiB | 100MiB | 128MiB | 256MiB |
--max-sql-memory=.4 --cache=.2 --max-go-memory=100MiB | 6.4GiB | 3.2GiB | 100MiB |
Explanation:
- in the first two lines we just use the default formula
2.25x --max-sql-memory
- in the third line, the default formula results in exceeding the upper
bound on total usage (including the cache), so we use the upper bound
determined as0.9 * total RAM - 1.15 * cache size
- in the fourth line, the default formula results in 225MiB which is
smaller than the lower bound of 256MiB, so we bump the value to that
lower bound - in the fifth line, we use the value specified by the user (even though
it is smaller than the lower bound on the default value).
Jira Issue: DOC-7165