Dmitrii Stepanov
32c77f3a23
Some checks failed
Build / Build Components (1.20) (pull_request) Successful in 4m6s
Build / Build Components (1.19) (pull_request) Successful in 4m18s
ci/woodpecker/pr/pre-commit Pipeline failed
Tests and linters / Lint (pull_request) Failing after 2m10s
Tests and linters / Tests with -race (pull_request) Has started running
Tests and linters / Tests (1.19) (pull_request) Successful in 3m58s
Tests and linters / Tests (1.20) (pull_request) Successful in 3m44s
Vulncheck / Vulncheck (pull_request) Failing after 3m51s
Tests and linters / Staticcheck (pull_request) Successful in 8m3s
ci/woodpecker/push/pre-commit Pipeline was successful
This parameter allows to set soft memory limit for Go GC. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
26 lines
684 B
Go
26 lines
684 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime/debug"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/runtime"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func setRuntimeParameters(c *cfg) {
|
|
if len(os.Getenv("GOMEMLIMIT")) != 0 {
|
|
// default limit < yaml limit < app env limit < GOMEMLIMIT
|
|
c.log.Warn(logs.RuntimeSoftMemoryDefinedWithGOMEMLIMIT)
|
|
return
|
|
}
|
|
|
|
memLimitBytes := runtime.GCMemoryLimitBytes(c.appCfg)
|
|
previous := debug.SetMemoryLimit(memLimitBytes)
|
|
if memLimitBytes != previous {
|
|
c.log.Info(logs.RuntimeSoftMemoryLimitUpdated,
|
|
zap.Int64("new_value", memLimitBytes),
|
|
zap.Int64("old_value", previous))
|
|
}
|
|
}
|