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
7da20a4b3f
commit
077193d87c
1 changed files with 7 additions and 5 deletions
|
@ -19,15 +19,17 @@ func init() {
|
|||
|
||||
func initGOGC() {
|
||||
if v := os.Getenv("GOGC"); v != "" {
|
||||
n, err := strconv.Atoi(v)
|
||||
n, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
n = 100
|
||||
}
|
||||
gogc = n
|
||||
gogc = int(n)
|
||||
} else {
|
||||
// Set GOGC to 50% by default if it isn't set yet.
|
||||
// This should reduce memory usage for typical workloads for VictoriaMetrics components.
|
||||
gogc = 50
|
||||
// Use lower GOGC if it isn't set yet.
|
||||
// This should reduce memory usage for typical workloads for VictoriaMetrics components
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue