mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
6721e47ae9
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
25 lines
671 B
Go
25 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)
|
|
}
|