Repository: prometheus/prometheus (language: go)

Issue:
Gogc is being set to 0 when installed with empty prometheus.yml file resulting high cpu usage
### What did you do?

Installed prometheus with empty prometheus.yml file and observed gogc being set to 0

### What did you expect to see?

As per prometheus documentation, gogc value will be set to 75 by default

By configuring explicitly gogc runtime to 75, usage of cpu is less after reloading the config


### What did you see instead? Under which circumstances?

Gogc value is being set to 0 , instead it should set to 75 by default

### System information

_No response_

### Prometheus version

```2.53.2

```

### Prometheus configuration file

```yaml

```

### Alertmanager version

```text

```

### Alertmanager configuration file

```yaml

```

### Logs

```text

```


Discussion / hints:
You're right, I came across this while adding some tests here https://github.com/prometheus/prometheus/pull/15238

Hi, during my investigation and debugging, I was able to reproduce the issue where the `GOGC` value defaults to `0` when using an empty `prometheus.yml` file. The issue arises in this function in `config.go`:
```
func Load(s string, logger *slog.Logger) (*Config, error) {
	cfg := &Config{}
	// If the entire config body is empty the UnmarshalYAML method is
	// never called. We thus have to set the DefaultConfig at the entry
	// point as well.
	*cfg = DefaultConfig

       // rest of the code....
}
```

**Issue**: The DefaultConfig was initially defined as:
```
DefaultConfig = Config{
    GlobalConfig: DefaultGlobalConfig,
}
```
This configuration did not include the Runtime settings. (which includes `GOGC` default value of `75`)

**Possible Solution**: To resolve this, The `DefaultConfig` can be modified to include Runtime: `DefaultRuntimeConfig` , ensuring that the `GOGC` value defaults to `75` as expected. The updated configuration is:
```
DefaultConfig = Config{
    GlobalConfig: DefaultGlobalConfig,
    Runtime:      DefaultRuntimeConfig,
}
```

Would it be okay for me to work on this and submit a PR? Let me know if you have any feedback or if any adjustments are needed before I proceed. Thanks!

Sure, feel free to propose a fix.
You can make use of my tests in https://github.com/prometheus/prometheus/pull/15238#issuecomment-2444673996

Fix patch:
diff --git a/config/config.go b/config/config.go
index 73282ac4295..3137094dde7 100644
--- a/config/config.go
+++ b/config/config.go
@@ -156,6 +156,7 @@ var (
 	// DefaultConfig is the default top-level configuration.
 	DefaultConfig = Config{
 		GlobalConfig: DefaultGlobalConfig,
+		Runtime:      DefaultRuntimeConfig,
 	}
 
 	// DefaultGlobalConfig is the default global configuration.


Test patch:
diff --git a/config/config_test.go b/config/config_test.go
index 437b858b002..faca7dda12b 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -2222,6 +2222,7 @@ func TestEmptyConfig(t *testing.T) {
 	exp := DefaultConfig
 	exp.loaded = true
 	require.Equal(t, exp, *c)
+	require.Equal(t, 75, c.Runtime.GoGC)
 }
 
 func TestExpandExternalLabels(t *testing.T) {
@@ -2269,7 +2270,6 @@ func TestEmptyGlobalBlock(t *testing.T) {
 	c, err := Load("global:\n", promslog.NewNopLogger())
 	require.NoError(t, err)
 	exp := DefaultConfig
-	exp.Runtime = DefaultRuntimeConfig
 	exp.loaded = true
 	require.Equal(t, exp, *c)
 }