-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add support to set gc percentage #25394
Conversation
Introduce new setting to Beats: gc_percentage The new setting sets GOGC, which configures the next gc limit. The default value is 100. Setting the percentage less to 100 makes the Beats trigger collection more often, due to a less next gc limit. In Agent we add per process type gc limit environment variables: APMSERVER_GOGC, FILEBEAT_GOGC, and METRICBEAT_GOGC. These can be used to fine tune gc percentage limit per sub process type
Pinging @elastic/agent (Team:Agent) |
"-E", "management.enabled=true", | ||
"-E", "management.mode=x-pack-fleet", | ||
"-E", "apm-server.data_streams.enabled=true" | ||
"-E", "gc_percent=${APMSERVER_GOGC:100}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works because libbeat merges all -E flags into the configuration. The environment variable with default will be evaluated by libbeat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
runtime.GOMAXPROCS(maxProcs) | ||
} | ||
if gcPercent := b.Config.GCPercent; gcPercent > 0 { | ||
logp.Info("Set gc percentage to: %v", gcPercent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth logging if the value is 100? Being that its the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only log if it is configured. Might be helpful to see all message when we have to compare configs with logs output in support cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the logs that are only logged once on startup (assuming this is correct) we should rather log too much then too little. Makes debugging easier.
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
@urso you need to run |
/test |
/test |
"-E", "management.mode=x-pack-fleet", | ||
"-E", "management.enabled=true", | ||
"-E", "logging.level=debug", | ||
"-E", "gc_percent=${METRICBEAT_GOGC:100}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FB / MB are enough for now, but I assume we will need to apply it to every Golang process / beat we run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if we find this works well, we will extend on this and document the env vars.
runtime.GOMAXPROCS(maxProcs) | ||
} | ||
if gcPercent := b.Config.GCPercent; gcPercent > 0 { | ||
logp.Info("Set gc percentage to: %v", gcPercent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the logs that are only logged once on startup (assuming this is correct) we should rather log too much then too little. Makes debugging easier.
/test |
This pull request is now in conflicts. Could you fix it? 🙏
|
(cherry picked from commit b21b87d)
(cherry picked from commit b21b87d) # Conflicts: # x-pack/elastic-agent/pkg/agent/program/supported.go
Co-authored-by: Steffen Siering <steffen.siering@elastic.co>
Co-authored-by: Steffen Siering <steffen.siering@elastic.co>
What does this PR do?
Introduce new setting to Beats: gc_percentage
The new setting sets GOGC, which configures the next gc limit. The
default value is 100. Setting the percentage less to 100 makes the Beats
trigger collection more often, due to a less next gc limit.
In Agent we add per process type gc limit environment variables:
APMSERVER_GOGC, FILEBEAT_GOGC, and METRICBEAT_GOGC.
These can be used to fine tune gc percentage limit per sub process type
Why is it important?
Allow users to set gc percentage.
Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Set gc_percentage in the configuration file or via
-E
. The Beat will print a log message (info level) on startup.