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

perf: auto set runtime maxprocs in docker #1339

Merged

Conversation

rfyiamcool
Copy link
Contributor

@rfyiamcool rfyiamcool commented Nov 4, 2023

summary

加入在容器环境中配置准确的并行度,go 的 runtime.maxprocs 默认读取的是宿主机的 cpu 配置,那么会存在一个问题。 服务 pod 通过 resource limit 配置了资源限制,比如物理机是 128 核心,而 pod 限定到 8 个核心,但 go init 实例化 runtime.maxprocs 时,按照物理机 cpu 资源配置,也就是会配置 128 个 gmp'p ,一定量级下,128 个线程想要并行处理,但 pod 的cpu为 8,如何让 128 个线程都得到运行 ? 时间片切得更细,让其在一个时间窗口内都得到 cpu 调度。使这些线程因为时间片到期,强制来回上下文切换,开销是不小的。

建议加上这个参数,尤其物理机 cpu 和 resource limit 差距较大时,服务的长尾很明显的。

几年前我做行情推送时,有遇到相关问题。另外,对该问题,写过一篇文章,大家可以参考下,https://xiaorui.cc/archives/6334

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Copy link
Contributor

sweep-ai bot commented Nov 4, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.

Copy link

codecov bot commented Nov 4, 2023

Codecov Report

Merging #1339 (3b0b8fe) into main (62e9980) will not change coverage.
Report is 1 commits behind head on main.
The diff coverage is n/a.

@@          Coverage Diff          @@
##            main   #1339   +/-   ##
=====================================
  Coverage   2.41%   2.41%           
=====================================
  Files         13      13           
  Lines        786     786           
=====================================
  Hits          19      19           
  Misses       764     764           
  Partials       3       3           

@FGadvancer FGadvancer added this pull request to the merge queue Nov 10, 2023
Merged via the queue into openimsdk:main with commit 005ff53 Nov 10, 2023
19 checks passed
@github-actions github-actions bot added this to the v3.1 milestone Nov 10, 2023
@openimsdk openimsdk locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants