-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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/geth: use automaxprocs to apply cpu quota correctly #27506
Conversation
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
I've checked the dependency a bit, and it's kind of complicated for what it is. Would be nice to have a simpler solution. |
We already have a package |
thanks for the advice, I'll try to implement it in the package |
Actually, after checking the automaxprocs implementation a bit more, I can say we probably don't want to reimplement this. |
@fjl please take another look, is it ready to merge? |
### Description upstream PR: [go-ethereum#27506](ethereum/go-ethereum#27506) As discussed with @rjl493456442 offline, if Geth was running in a container with CPU quota(set with cgroup limiting), and runtime.NumCPU returns the host's CPU cores(maybe bigger than the docker's setting), which may result in more Golang runtime schedule and context switch. So I'm using the [uber/atomaxprocs](https://github.com/uber-go/automaxprocs) package to return the correct cpu quota.
It is usually best to set GOMAXPROCS to the number of available CPU cores. However, setting it like that does not work well when the process is quota-limited to a certain number of CPUs. The automaxprocs library configures GOMAXPROCS, taking such limits into account.
…reum#27506)" This reverts commit 098c798.
…reum#27506)" This reverts commit 098c798.
As discussed with @rjl493456442 offline, if Geth was running in a container with CPU quota(set with cgroup limiting), and
runtime.NumCPU
returns the host's CPU cores(maybe bigger than the docker's setting), which may result in more Golang runtime schedule and context switch.So I'm using the uber/atomaxprocs package to return the correct cpu quota.