Enable auto-gomaxprocs by default (#15378)

Enable the `auto-gomaxprocs` feature flag by default.
* Add command line flag `--no-auto-gomaxprocs` to disable.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie 2024-11-12 13:27:01 +01:00 committed by GitHub
parent 49999b8a90
commit 869addfec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 11 deletions

View file

@ -195,6 +195,7 @@ type flagConfig struct {
enableAutoReload bool
autoReloadInterval model.Duration
maxprocsEnable bool
memlimitEnable bool
memlimitRatio float64
@ -202,7 +203,6 @@ type flagConfig struct {
// These options are extracted from featureList
// for ease of use.
enablePerStepStats bool
enableAutoGOMAXPROCS bool
enableConcurrentRuleEval bool
prometheusURL string
@ -234,9 +234,6 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
case "promql-per-step-stats":
c.enablePerStepStats = true
logger.Info("Experimental per-step statistics reporting")
case "auto-gomaxprocs":
c.enableAutoGOMAXPROCS = true
logger.Info("Automatically set GOMAXPROCS to match Linux container CPU quota")
case "auto-reload-config":
c.enableAutoReload = true
if s := time.Duration(c.autoReloadInterval).Seconds(); s > 0 && s < 1 {
@ -329,6 +326,8 @@ func main() {
a.Flag("web.listen-address", "Address to listen on for UI, API, and telemetry. Can be repeated.").
Default("0.0.0.0:9090").StringsVar(&cfg.web.ListenAddresses)
a.Flag("auto-gomaxprocs", "Automatically set GOMAXPROCS to match Linux container CPU quota").
Default("true").BoolVar(&cfg.maxprocsEnable)
a.Flag("auto-gomemlimit", "Automatically set GOMEMLIMIT to match Linux container or system memory limit").
Default("true").BoolVar(&cfg.memlimitEnable)
a.Flag("auto-gomemlimit.ratio", "The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory").
@ -756,7 +755,7 @@ func main() {
ruleManager *rules.Manager
)
if cfg.enableAutoGOMAXPROCS {
if cfg.maxprocsEnable {
l := func(format string, a ...interface{}) {
logger.Info(fmt.Sprintf(strings.TrimPrefix(format, "maxprocs: "), a...), "component", "automaxprocs")
}

View file

@ -17,6 +17,7 @@ The Prometheus monitoring server
| <code class="text-nowrap">--config.file</code> | Prometheus configuration file path. | `prometheus.yml` |
| <code class="text-nowrap">--config.auto-reload-interval</code> | Specifies the interval for checking and automatically reloading the Prometheus configuration file upon detecting changes. | `30s` |
| <code class="text-nowrap">--web.listen-address</code> <code class="text-nowrap">...<code class="text-nowrap"> | Address to listen on for UI, API, and telemetry. Can be repeated. | `0.0.0.0:9090` |
| <code class="text-nowrap">--auto-gomaxprocs</code> | Automatically set GOMAXPROCS to match Linux container CPU quota | `true` |
| <code class="text-nowrap">--auto-gomemlimit</code> | Automatically set GOMEMLIMIT to match Linux container or system memory limit | `true` |
| <code class="text-nowrap">--auto-gomemlimit.ratio</code> | The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory | `0.9` |
| <code class="text-nowrap">--web.config.file</code> | [EXPERIMENTAL] Path to configuration file that can enable TLS or authentication. | |

View file

@ -47,12 +47,6 @@ statistics. Currently this is limited to totalQueryableSamples.
When disabled in either the engine or the query, per-step statistics are not
computed at all.
## Auto GOMAXPROCS
`--enable-feature=auto-gomaxprocs`
When enabled, GOMAXPROCS variable is automatically set to match Linux container CPU quota.
## Native Histograms
`--enable-feature=native-histograms`