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

cmd/dist: feature request: control over maximum number of CPUs used during build and test #22445

odysseus9672 opened this issue Oct 25, 2017 · 3 comments


Copy link

@odysseus9672 odysseus9672 commented Oct 25, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version
go version devel +a31e0a4aac Sat Oct 21 11:32:53 2017 +0000 darwin/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/75/tsmllrjr8xl81b0059bfyyd00000gs/T/go-build923680158=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Invoke all.bash after updating with git fetch and git pull.

What did you expect to see?

No more than $GOMAXPROCS used during the build and testing process.

What did you see instead?

Every processor available being utilized.

I really like to be able to limit the number of logical processors that the build and test process Go uses. The logical choice would be for the process to respect the environment variable GOMAXPROCS. The reason for wanting to impose this limit is to manage the amount of heat produced on my system during the process.

Copy link

@ianlancetaylor ianlancetaylor commented Oct 26, 2017

As far as I know the build part will honor GOMAXPROCS. However, some of the tests will intentionally modify GOMAXPROCS and may reset based on the number of CPUs on the machine. Let us know if this does not match your observations.

Since what matters is basically the default value of GOMAXPROCS, on GNU/Linux you could do what you want by running all.bash via the taskset command. Does Darwin have a similar program?

@ianlancetaylor ianlancetaylor changed the title Feature Request: Control over maximum number of CPUs used when invoking $GOROOT/src/all.bash cmd/dist: feature request: control over maximum number of CPUs used during build and test Oct 26, 2017
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 26, 2017
Copy link

@odysseus9672 odysseus9672 commented Oct 26, 2017

I just tried a run with export GOMAXPROCS=1, and the build process frequently used more than one CPU, though not as often as when it was set higher. I'm unsure of whether this bit of documentation is sufficient to explain that:

The GOMAXPROCS variable limits the number of operating system threads that can execute user-level Go code simultaneously. There is no limit to the number of threads that can be blocked in system calls on behalf of Go code; those do not count against the GOMAXPROCS limit. This package's GOMAXPROCS function queries and changes the limit.

from: .

Also, my attempts to find info on Max OS X cpu affinity reveals this, though it may be dated by now. man cpuset and man taskset both yield nothing.

Copy link

@odysseus9672 odysseus9672 commented Oct 26, 2017

Maybe GOMAXPROCS isn't the correct way to go, since that controls running programs. Perhaps an argument similar to the maximum number of jobs specifiable as an argument to make (e.g. make -j 2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants