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

feat(env): support GOGC default value #7776

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dongjiang1989
Copy link
Contributor

@dongjiang1989 dongjiang1989 commented Sep 23, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Adjust from the Go default of 100 to 75 to reduce wasted memory.

Verification

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
Copy link
Contributor

@pedro-stanaka pedro-stanaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have the default behavior from the runtime as the default value, and let users decide what works best for them.

@@ -45,6 +46,10 @@ import (
// Name is the name registered for the proto compressor.
const Name = "proto"

// Use lower GOGC if it isn't set yet.
// It is recommended increasing GOGC if go_memstats_gc_cpu_fraction exceeds 0.05 for extended periods of time.
const DefaultGOGC = 75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the user be responsible for tweaking this to make it work for their setup? I believe some CPU heavy/bound workloads like receivers will suffer from this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For advanced users it is reserved for the user to adjust it to suit their setup, but in container scenarios giving it a default value (which is pretty good) is more suitable for most scenarios.

Signed-off-by: dongjiang <dongjiang1989@126.com>
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
@dongjiang1989
Copy link
Contributor Author

进一步查看数据,从 100 到 75 的变化会导致内存使用量减少约 15%,而 CPU 使用量增加约 10%。

相比GOGC=50,CPU消耗增加了20%,但内存减少了40%。

我认为对于此更改的第一次迭代,我们应该减轻 CPU 增量并使用 GOGC=75。
https://github.com/prometheus/prometheus/releases/tag/v2.53.0

调整默认 GOGC prometheus/prometheus#14285
添加 GOGC 的配置选项,默认为 50 prometheus/prometheus#14176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants