Merged
新增KAOT插件 #88
新增KAOT插件 #88
Merged
chrisffjxAdd on Sep 1
chrisffjx
chrisffjxCollaborators
Sep 1

功能说明

新增 KAOT 基础系统调优能力,覆盖内存大页、SMT、内存过量分配、Swap、透明大页、CPU 性能模式和 I/O 队列调度器等常用操作系统优化项。

主要改动

  • 新增内存大页配置:

    • 获取当前大页配置。
    • 校验大页规格和数量。
    • 更新 GRUB 和 /etc/fstab 配置。
    • 生成并应用系统大页参数。
  • 新增 SMT 配置:

    • 获取当前 SMT 状态。
    • 支持将系统配置为 SMT2 模式。
  • 新增内存相关调优项:

    • 禁用内存过量分配。
    • 禁用 Swap。
    • 禁用透明大页及透明大页碎片整理。
  • 新增 CPU 性能模式:

    • 获取当前 CPU 调频模式。
    • 更新 GRUB 中的 CPU 调频参数。
    • 将 CPU 设置为 performance 模式。
  • 新增 I/O 队列调度器优化:

    • 自动识别系统块设备。
    • 根据磁盘类型选择调度策略。
    • 生成并应用 udev 规则。
    • 支持重新加载并触发设备规则。
  • 完善文件编码、子进程返回码检查和异常处理。

测试结果

  • pre-commit 全部检查通过:

    • Ruff Check
    • Ruff Format
    • Pylint
    • Bandit
    • Codespell
    • Typos
  • 干净检出环境验证通过。

  • KAOT 命令行模块加载正常。

  • 当前累计 10 个调优项自动发现和注册正常。

  • Python 语法编译检查通过。

  • GitCode 远端 Git Hooks 检查通过。

关联 Issue

Feature:支持 KAOT 插件进行 OS 配置

likedislike
Pull Request has been successfully merged by ascend-robot.
(Thank you for chrisffjx's contribution.)
chrisffjxchrisffjxCollaborators
Sep 1 Associated issue: [Feature]:支持KAOT插件进行os配置
atomgit-bot
atomgit-bot
Sep 1 Comments:

变更摘要

本 PR 为 KAOT 新增基础系统调优能力,通过 register_feature 装饰器注册 7 个继承自 BaseFeature 的调优特性模块(均实现 get_current_config 与 _apply_config_impl),覆盖内存大页、SMT、内存过量分配、Swap、透明大页、CPU 性能模式和 I/O 队列调度器等操作系统优化项,并在各模块中完善了文件编码(encoding="utf-8")、子进程返回码检查(check=True/returncode)与异常处理。

主要改动

  • 内存大页配置 config_hugepages.py:从 /etc/default/grub 的 GRUB_CMDLINE_LINUX 行解析当前 hugepagesz/hugepages,校验大页规格(对比 /sys/kernel/mm/hugepages 支持值)和数量(对比 /proc/meminfo 总内存),通过 update_grub_cmdline 更新 GRUB 参数,并视情况向 /etc/fstab 追加 hugetlbfs 挂载项后执行 grub2-mkconfig 生成引导配置。
  • SMT 配置 config_smt2.py:通过 lscpu 解析 Thread(s) per core 获取当前 SMT 状态,校验 SMT2_status 取值,检测虚机环境(systemd-detect-virt)与 920 平台型号(dmidecode),并通过 _show_smt_hint 输出 BIOS 手工配置指南提示。
  • 内存相关调优项:新增 disable_memory_overcommit.py(校验并写入 vm.zone_reclaim_mode 到 /etc/sysctl.conf)、disable_swap.py(校验 0–80 范围并写入 vm.swappiness)、disable_transparent_hugepages.py(校验 enabled/defrag 合法取值,生成或修改 kaot.service systemd 服务并执行 daemon-reload/enable/start 以禁用透明大页及碎片整理)。
  • CPU 性能模式 enable_cpu_performance_mode.py:解析 GRUB 中现有 cpufreq.default_governor 参数,按内核版本(4.7+ 支持 schedutil)校验调速器取值,通过 _update_grub 更新 GRUB 并重新生成引导配置,将 CPU 设置为 performance 模式。
  • I/O 队列调度器优化 optimize_io_queue_scheduler.py:通过 lsblk 识别系统块设备,依据 rotational 与 discard_granularity 判断 SSD,将 SSD 调度策略设为 none 并生成 /etc/udev/rules.d/io-queue-scheduler.rules 规则文件,随后执行 udevadm control --reload-rules 与 udevadm trigger 重载并应用规则。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 1 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
ascend-robotascend-robotCollaborators
Sep 1 Added label: ascend-cla/yes
ascend-robot
ascend-robotCollaborators
Sep 1 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/msboost ✅ a-young-journey, LiuYongQiang0816 (2/2) ✅ a-young-journey (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
chrisffjx
chrisffjxCollaborators
Sep 1 Comments:

compile

likedislike
AtlasAccountAtlasAccountCollaborators
Sep 1 Added label: ci-pipeline-running
AtlasAccountAtlasAccountCollaborators
Sep 1 Removed label: ci-pipeline-running
AtlasAccountAtlasAccountCollaborators
Sep 1 Added label: ci-pipeline-passed
AtlasAccount
AtlasAccountCollaborators
Sep 1 Comments:
流水线 PR-pipeline_msboost#156 [ commitID:a9554f64 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
恶意代码检查 Antipoison ✅ COMPLETED >>>
流水线 PR-pipeline_msboost ✅ COMPLETED >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
a-young-journey
a-young-journeyCollaborators
Sep 2 Comments:

/approve
/lgtm

likedislike
ascend-robotascend-robotCollaborators
Sep 2 Added label: approved
LiuYongQiang
LiuYongQiangCollaborators
Sep 2 Comments:

/lgtm

likedislike
ascend-robotascend-robotCollaborators
Sep 2 Added label: lgtm
ascend-robotascend-robotCollaborators
Sep 2 Merged pull request, merge node SHA: 8e9861d244e0487688919bc9c40739858f7225d5