Merged
perf(orchestrator): use a single NBD connection per device on Linux 4.19 #240
perf(orchestrator): use a single NBD connection per device on Linux 4.19 #240
Merged
xhmljaAdd on Oct 26
xhmlja
xhmlja
Oct 26

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

参考:openEuler社区《生成式AI工具使用与开源贡献政策》

PR功能描述 / 为什么需要这个合入**:

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request has been successfully merged by openeuler-ci-bot.
(Thank you for xhmlja's contribution.)
xhmljaxhmlja
Oct 26 Created pull request, commit ff9dde61
atomgit-bot
atomgit-bot
Oct 26 Comments:

变更摘要

本 PR 针对 Linux 4.19 内核(如 openEuler 20.03 LTS)上 NBD 设备连接数过多导致的启动性能问题做优化。由于每次为 NBD 设备附加 socket 都会冻结该设备的块队列,而各设备的 nbd netlink 命令又在内核全局锁下串行化,4.19 内核的每次冻结还需等待 RCU 宽限期,使得并发启动沙箱被额外连接阻塞。改动新增 hostkernel 包用于识别宿主内核版本,并在 DirectPathMount.Open 中通过 connectionsPerDevice 将 4.19 内核的每设备连接数收敛为 1,其他内核仍沿用特性开关 NBDConnectionsPerDevice 的取值。

主要改动

  • 新增内核版本检测包: 新增 packages/shared/pkg/hostkernel/hostkernel.go,通过 unix.Uname 读取内核 release 字符串,并用 sync.OnceValue 缓存结果,提供 IsLinux419();内部 isLinux419Release 以精确匹配 4.19 或前缀 4.19. 判定版本。
  • 新增每设备连接数决策函数: path_direct.go 中新增 connectionsPerDevice(flagValue int, linux419 bool) int,当内核为 4.19 且特性开关值大于 1 时返回 1,否则原样返回开关值。
  • 接入沙箱 NBD 挂载流程: DirectPathMount.Open 改为先用 d.featureFlags.IntFlag(ctx, featureflags.NBDConnectionsPerDevice) 读取配置,再结合 hostkernel.IsLinux419() 经 connectionsPerDevice 计算实际 socket 数,据此创建 socksServer 与 dispatchers。
  • 依赖调整: packages/shared/go.mod 中 golang.org/x/sys 由 indirect 依赖提升为直接依赖,以支持 unix.Uname。
  • 新增单元测试: 新增 connections_test.go 与 hostkernel_test.go,分别覆盖不同内核/开关组合下的连接数返回值,以及 4.19、4.19.90-... 等 release 字符串的判定边界(如 4.190、14.19.1、空串返回 false)。
likedislike
Incorrect?
openeuler-ci-botopeneuler-ci-botCollaborators
Oct 26 Set weibaohui,yangzhao_kl,jimmieme,duguhaotian,wonleing,zmr_2020,gaodaweiky,lu-wei-army,zhaoyifan28 as approver
atomgit-bot
atomgit-bot
Oct 26 Comments:

代码审查

✅ 未发现问题,不过下面列了 1 处不太确定的地方,供你参考


🔍 另有 1 处,仅供参考(不影响合并)

下面这些地方 AI 觉得有点可疑,但把握不大,所以没有当成正式问题,也没有在代码行上留评论。列在这里只是多给你一个视角:觉得有道理可以顺手看看,觉得是误报直接忽略就行。

  • packages/orchestrator/internal/sandbox/nbd/connections_test.go:18 — test: 补充 flagValue 为 0 / 负数的边界用例
likedislike
Incorrect?
openeuler-ci-botopeneuler-ci-botCollaborators
Oct 26 Added label: sig/sig-CloudNative
openeuler-ci-bot
openeuler-ci-botCollaborators
Oct 26 Comments:

Welcome To openEuler Community

Hey @xhmlja , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: sig-CloudNative ,
and any of the maintainers: @duguhaotian, @gaodaweiky, @jimmieme, @lu-wei-army, @weibaohui, @wonleing, @yangzhao_kl, @zhaoyifan28, @zmr_2020 ,
and any of the committers: @feijianqiang, @zhourenjianz .

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Oct 26 Added label: openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-botCollaborators
Oct 26 Comments:

CLA Signature Pass

xhmlja, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-botopeneuler-botCollaborators
Oct 26 Added label: ci_processing
openeuler-bot
openeuler-botCollaborators
Oct 26 Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/KASandbox/525

likedislike
openeuler-botopeneuler-botCollaborators
Oct 26 Removed label: ci_processing
openeuler-bot
openeuler-botCollaborators
Oct 26 Comments:
Check Name Build Result 详情 Build Details
check_package_license ✅SUCCESS #525
check_sca ✅SUCCESS
x86_64 check_build ✅SUCCESS #528
aarch64 check_build ✅SUCCESS #544
DT check_build ✅SUCCESS #541
likedislike
openeuler-botopeneuler-botCollaborators
Oct 26 Added label: ci_successful
openeuler-bot
openeuler-botCollaborators
Oct 26 Comments:
likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
29 days ago Added label: approvedlgtm
openeuler-ci-bot
openeuler-ci-botCollaborators
29 days ago Comments:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that zhourenjianz reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
zhourenjian
zhourenjianCollaborators
29 days ago Comments:

/lgtm

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
29 days ago Merged pull request, merge node SHA: dbb6268834fb01236b4310aec02ae44bc4bc95be