Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Go garbage collection target percentage to 400% #5034

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### 💡 Enhancements 💡

- (Splunk) Set Go garbage collection target percentage to 400% ([#5034](https://github.com/signalfx/splunk-otel-collector/pull/5034))
After removal of memory_ballast extension in v0.97.0, the Go garbage collection is running more aggressively, which
increased CPU usage and leads to reduced throughput of the collector. This change reduces the frequency of garbage
collection cycles to improves performance of the collector for typical workloads. As a result, the collector will
report higher memory usage, but it will be bound to the same configured limits. If you want to revert to the previous
behavior, set the `GOGC` environment variable to `100`.

### 🧰 Bug fixes 🧰

- (Splunk) `receiver/discovery`: Do not emit entity events for discovered endpoints that are not evaluated yet
Expand Down
7 changes: 7 additions & 0 deletions internal/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
HecLogIngestURLEnvVar = "SPLUNK_HEC_URL"
ListenInterfaceEnvVar = "SPLUNK_LISTEN_INTERFACE"
GoMemLimitEnvVar = "GOMEMLIMIT"
GoGCEnvVar = "GOGC"
// nolint:gosec
HecTokenEnvVar = "SPLUNK_HEC_TOKEN" // this isn't a hardcoded token
IngestURLEnvVar = "SPLUNK_INGEST_URL"
Expand All @@ -59,6 +60,7 @@ const (

DefaultMemoryLimitPercentage = 90
DefaultMemoryTotalMiB = 512
DefaultGoGC = 400
DefaultListenInterface = "0.0.0.0"
DefaultAgentConfigLinux = "/etc/otel/collector/agent_config.yaml"
featureGates = "feature-gates"
Expand Down Expand Up @@ -371,6 +373,11 @@ func checkRuntimeParams(settings *Settings) error {
setSoftMemoryLimit(memTotalSize)
}

if _, ok := os.LookupEnv(GoGCEnvVar); !ok {
debug.SetGCPercent(DefaultGoGC)
log.Printf("Set garbage collection target percentage (GOGC) to %d", DefaultGoGC)
}

return nil
}

Expand Down
Loading