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

Update GOMAXPROCS configuration #4013

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Update GOMAXPROCS configuration #4013

merged 1 commit into from
Sep 4, 2024

Conversation

lou-lan
Copy link
Collaborator

@lou-lan lou-lan commented Sep 4, 2024

fix #3993, Update GOMAXPROCS configuration

  • Replace manual GOMAXPROCS setting with maxprocs package for improved handling.
  • Log a warning if setting GOMAXPROCS fails.
  • Ensure min value is used when setting max procs from configuration.

if currentP > int(controllerContext.Cfg.GoMaxProcs) {
p := runtime.GOMAXPROCS(int(controllerContext.Cfg.GoMaxProcs))
logger.Sugar().Infof("Change max golang procs to %d", p)
if _, err := maxprocs.Set(maxprocs.Min(controllerContext.Cfg.GoMaxProcs)); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

1 是否有日志,能看到 设置效果
2 代码中 简短的 comment。说明下 设置为多少了

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

{"level":"INFO","ts":"2024-09-04T05:27:16.125Z","logger":"spiderpool-controller","caller":"cmd/daemon.go:74","msg":"maxprocs: Updating GOMAXPROCS=1: using minimum allowed GOMAXPROCS"}

调高 limit,GOMAXPROCS 也相应增加

{"level":"INFO","ts":"2024-09-04T05:28:26.389Z","logger":"spiderpool-controller","caller":"cmd/daemon.go:74","msg":"maxprocs: Updating GOMAXPROCS=2: determined from CPU quota"}

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (e409b4d) to head (6d241a4).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4013   +/-   ##
=======================================
  Coverage   80.83%   80.83%           
=======================================
  Files          51       51           
  Lines        4514     4514           
=======================================
  Hits         3649     3649           
  Misses        699      699           
  Partials      166      166           
Flag Coverage Δ
unittests 80.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@lou-lan lou-lan force-pushed the fix/GOMAXPROCS branch 2 times, most recently from 883d2c4 to 09884b1 Compare September 4, 2024 05:03
@weizhoublue weizhoublue added cherrypick-release-v0.8 Cherry-pick the PR to branch release-v0.8. cherrypick-release-v0.9 labels Sep 4, 2024
- Replace manual GOMAXPROCS setting with maxprocs package for improved handling.
- Log a warning if setting GOMAXPROCS fails.
- Ensure min value is used when setting max procs from configuration.

Signed-off-by: lou-lan <loulan@loulan.me>
@weizhoublue weizhoublue added cherrypick-release-v1.0 Cherry-pick the PR to branch release-v1.0. and removed cherrypick-release-v0.9 labels Sep 4, 2024
@weizhoublue weizhoublue merged commit 922aa5a into main Sep 4, 2024
54 checks passed
@weizhoublue weizhoublue deleted the fix/GOMAXPROCS branch September 4, 2024 05:39
github-actions bot pushed a commit that referenced this pull request Sep 4, 2024
Update GOMAXPROCS configuration

Signed-off-by: robot <tao.yang@daocloud.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick-release-v0.8 Cherry-pick the PR to branch release-v0.8. cherrypick-release-v1.0 Cherry-pick the PR to branch release-v1.0. release/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize setting max golang procs
2 participants