mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/cgroup: reduce the default GOGC value from 50% to 30%
This reduces memory usage under production workloads by up to 10%, while CPU spent on GC remains roughly the same. The CPU spent on GC can be monitored with go_memstats_gc_cpu_fraction metric
This commit is contained in:
parent
f082e64e0c
commit
f526c7814e
1 changed files with 7 additions and 5 deletions
|
@ -19,15 +19,17 @@ func init() {
|
||||||
|
|
||||||
func initGOGC() {
|
func initGOGC() {
|
||||||
if v := os.Getenv("GOGC"); v != "" {
|
if v := os.Getenv("GOGC"); v != "" {
|
||||||
n, err := strconv.Atoi(v)
|
n, err := strconv.ParseFloat(v, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
n = 100
|
n = 100
|
||||||
}
|
}
|
||||||
gogc = n
|
gogc = int(n)
|
||||||
} else {
|
} else {
|
||||||
// Set GOGC to 50% by default if it isn't set yet.
|
// Use lower GOGC if it isn't set yet.
|
||||||
// This should reduce memory usage for typical workloads for VictoriaMetrics components.
|
// This should reduce memory usage for typical workloads for VictoriaMetrics components
|
||||||
gogc = 50
|
// at the cost of increased CPU usage.
|
||||||
|
// It is recommended increasing GOGC if go_memstats_gc_cpu_fraction exceeds 0.05 for extended periods of time.
|
||||||
|
gogc = 30
|
||||||
debug.SetGCPercent(gogc)
|
debug.SetGCPercent(gogc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue