forked from TrueCloudLab/frostfs-node
27 lines
726 B
Go
27 lines
726 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"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(ctx context.Context, c *cfg) {
|
|
if len(os.Getenv("GOMEMLIMIT")) != 0 {
|
|
// default limit < yaml limit < app env limit < GOMEMLIMIT
|
|
c.log.Warn(ctx, logs.RuntimeSoftMemoryDefinedWithGOMEMLIMIT)
|
|
return
|
|
}
|
|
|
|
memLimitBytes := runtime.GCMemoryLimitBytes(c.appCfg)
|
|
previous := debug.SetMemoryLimit(memLimitBytes)
|
|
if memLimitBytes != previous {
|
|
c.log.Info(ctx, logs.RuntimeSoftMemoryLimitUpdated,
|
|
zap.Int64("new_value", memLimitBytes),
|
|
zap.Int64("old_value", previous))
|
|
}
|
|
}
|