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

core/go: use max procs #4766

Merged
merged 4 commits into from Dec 7, 2023
Merged

core/go: use max procs #4766

merged 4 commits into from Dec 7, 2023

Conversation

calebdoxsey
Copy link
Contributor

Summary

Use automaxprocs to set GOMAXPROCS to the cgroup limits for containers. Also use GOMAXPROCS instead of runtime.NumCPU.

Related issues

Checklist

  • reference any related issues
  • updated unit tests
  • add appropriate tag (improvement / bug / etc)
  • ready for review

@@ -20,7 +20,7 @@ func Build[T any](
builders ...BuilderFunc[T],
) ([]*T, []error) {
eg, ctx := errgroup.WithContext(ctx)
eg.SetLimit(runtime.NumCPU()/2 + 1)
eg.SetLimit(runtime.GOMAXPROCS(0)/2 + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this consider both GOMAXPROCS and NumCPU, and base the limit on whichever is lower?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the purpose of this was. It sounds like it was put in place to avoid CPU starvation, but Go has had a pre-emptive scheduler for a while now, so starvation shouldn't be an issue.

@wasaga what do you think it should do?

@coveralls
Copy link

Coverage Status

coverage: 62.369% (+0.01%) from 62.356%
when pulling fd009ae on cdoxsey/automaxprocs
into 9db828f on main.

@calebdoxsey calebdoxsey merged commit ce8abde into main Dec 7, 2023
9 checks passed
@calebdoxsey calebdoxsey deleted the cdoxsey/automaxprocs branch December 7, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants