mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-16 18:17:35 +02:00
[BUGFIX] Top-level: Update GOGC before loading TSDB
We should use the configured value, or Prometheus' default of 75%, while initializing and loading the WAL. Since the Go default is 100%, most Prometheus users would experience higher memory usage before the value is configured. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
a8a4b7ce69
commit
284914c8db
@ -617,6 +617,7 @@ func main() {
|
||||
if cfgFile.StorageConfig.TSDBConfig != nil {
|
||||
cfg.tsdb.OutOfOrderTimeWindow = cfgFile.StorageConfig.TSDBConfig.OutOfOrderTimeWindow
|
||||
}
|
||||
updateGoGC(cfgFile, logger)
|
||||
|
||||
// Now that the validity of the config is established, set the config
|
||||
// success metrics accordingly, although the config isn't really loaded
|
||||
@ -1472,6 +1473,14 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg
|
||||
return fmt.Errorf("one or more errors occurred while applying the new configuration (--config.file=%q)", filename)
|
||||
}
|
||||
|
||||
updateGoGC(conf, logger)
|
||||
|
||||
noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval)
|
||||
timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start))
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateGoGC(conf *config.Config, logger *slog.Logger) {
|
||||
oldGoGC := debug.SetGCPercent(conf.Runtime.GoGC)
|
||||
if oldGoGC != conf.Runtime.GoGC {
|
||||
logger.Info("updated GOGC", "old", oldGoGC, "new", conf.Runtime.GoGC)
|
||||
@ -1482,10 +1491,6 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg
|
||||
} else {
|
||||
os.Setenv("GOGC", "off")
|
||||
}
|
||||
|
||||
noStepSuqueryInterval.Set(conf.GlobalConfig.EvaluationInterval)
|
||||
timingsLogger.Info("Completed loading of configuration file", "filename", filename, "totalDuration", time.Since(start))
|
||||
return nil
|
||||
}
|
||||
|
||||
func startsOrEndsWithQuote(s string) bool {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user