mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
ef7e2af8f5
Update GOMAXPROCS to limits set via cgroups. This should reduce CPU trashing and reduce memory usage for cases when VictoriaMetrics components run in containers with CPU limits. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/685
24 lines
671 B
Go
24 lines
671 B
Go
package cgroup
|
|
|
|
import (
|
|
"bytes"
|
|
"io/ioutil"
|
|
"os/exec"
|
|
"strconv"
|
|
)
|
|
|
|
func readInt64(path, altCommand string) (int64, error) {
|
|
data, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
// Read data according to https://unix.stackexchange.com/questions/242718/how-to-find-out-how-much-memory-lxc-container-is-allowed-to-consume
|
|
// This should properly determine the data location inside lxc container.
|
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/84
|
|
cmd := exec.Command("/bin/sh", "-c", altCommand)
|
|
data, err = cmd.Output()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
data = bytes.TrimSpace(data)
|
|
return strconv.ParseInt(string(data), 10, 64)
|
|
}
|