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

fix setting GOMAXPROCS #853

Merged
merged 1 commit into from
May 19, 2023
Merged

fix setting GOMAXPROCS #853

merged 1 commit into from
May 19, 2023

Conversation

wulorn
Copy link
Contributor

@wulorn wulorn commented May 10, 2023

不需要显示设置GOMAXPROCS,未设置时默认值就是runtime.NumCPU,设置后因为init的执行顺序会影响在容器中设置的环境变量

GOMAXPROCS 是 Golang 提供的非常重要的一个环境变量设定。通过设定 GOMAXPROCS,可以调整 Runtime Scheduler 中 Processor(简称P)的数量。由于每个系统线程,必须要绑定 P 才能真正地进行执行。所以 P 的数量会很大程度上影响 Golang Runtime 的并发表现。GOMAXPROCS 一般的默认值是 CPU 核数,在容器中一般会通过 cgroup 等技术对 CPU 资源进行隔离。

issues #851

@wulorn wulorn changed the title Fix P(processor) in the runtime scheduler GOMAXPROCS sets the maximum number of CPUs that can be executing simultaneously and returns the previous setting. It defaults to the value of runtime.NumCPU May 10, 2023
@wulorn wulorn changed the title GOMAXPROCS sets the maximum number of CPUs that can be executing simultaneously and returns the previous setting. It defaults to the value of runtime.NumCPU fix setting GOMAXPROCS. It defaults to the value of runtime.NumCPU May 10, 2023
simultaneously and returns the previous setting. It defaults to
the value of runtime.NumCPU
@wulorn
Copy link
Contributor Author

wulorn commented May 11, 2023

不需要显示设置GOMAXPROCS,未设置时默认值就是runtime.NumCPU,设置后因为init的执行顺序会影响在容器中设置的环境变量

GOMAXPROCS 是 Golang 提供的非常重要的一个环境变量设定。通过设定 GOMAXPROCS,可以调整 Runtime Scheduler 中 Processor(简称P)的数量。由于每个系统线程,必须要绑定 P 才能真正地进行执行。所以 P 的数量会很大程度上影响 Golang Runtime 的并发表现。GOMAXPROCS 一般的默认值是 CPU 核数,在容器中一般会通过 cgroup 等技术对 CPU 资源进行隔离。

issues #851

参考链接: https://pkg.go.dev/runtime#GOMAXPROCS
image

@wulorn wulorn changed the title fix setting GOMAXPROCS. It defaults to the value of runtime.NumCPU fix setting GOMAXPROCS May 11, 2023
@jinzhu jinzhu merged commit d89f033 into go-gorm:master May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants