From 49a6b6e39dc59880676026f4f2d32f2581f1b4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=BC=80=E5=AE=89?= Date: Sat, 30 Mar 2024 09:28:49 +0800 Subject: [PATCH] =?UTF-8?q?A-FOT=E5=AE=89=E8=A3=85=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=8C=87=E5=AF=BC=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + ...07\345\257\274\350\257\264\346\230\216.md" | 206 ++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 "document/A-FOT\345\256\211\350\243\205\351\203\250\347\275\262\346\214\207\345\257\274/A-FOT\345\256\211\350\243\205\344\275\277\347\224\250\344\273\245\345\217\212\351\233\206\346\210\220\345\210\260Jenkins\346\214\207\345\257\274\350\257\264\346\230\216.md" diff --git a/README.md b/README.md index 7a25caf..b634840 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Pipeline solution to support building, deploying and automating any software pro 3. [Jenkins流水线无感切换bisheng编译器](https://gitee.com/openeuler/devkit-pipeline/blob/master/document/无感切换/无感切换与Jenkins集成部署指导手册.md) 4. [Jenkins流水线配置Java性能分析](document/Jenkins安装部署/Jenkins流水线配置Java性能分析.md) 5. [clamAV安装部署指导](document/clamAV安装更新指导/clamav安装部署指导资料.md) + 1. [A-FOT安装部署指导](document/A-FOT安装部署指导/A-FOT安装使用以及集成到Jenkins指导说明.md) + ###### 原子能力对接流水线实践指导 (Gitlab) DevKit各原子能力对接Gitlab流水线的脚本范例及使用说明 diff --git "a/document/A-FOT\345\256\211\350\243\205\351\203\250\347\275\262\346\214\207\345\257\274/A-FOT\345\256\211\350\243\205\344\275\277\347\224\250\344\273\245\345\217\212\351\233\206\346\210\220\345\210\260Jenkins\346\214\207\345\257\274\350\257\264\346\230\216.md" "b/document/A-FOT\345\256\211\350\243\205\351\203\250\347\275\262\346\214\207\345\257\274/A-FOT\345\256\211\350\243\205\344\275\277\347\224\250\344\273\245\345\217\212\351\233\206\346\210\220\345\210\260Jenkins\346\214\207\345\257\274\350\257\264\346\230\216.md" new file mode 100644 index 0000000..9462b2a --- /dev/null +++ "b/document/A-FOT\345\256\211\350\243\205\351\203\250\347\275\262\346\214\207\345\257\274/A-FOT\345\256\211\350\243\205\344\275\277\347\224\250\344\273\245\345\217\212\351\233\206\346\210\220\345\210\260Jenkins\346\214\207\345\257\274\350\257\264\346\230\216.md" @@ -0,0 +1,206 @@ +# A-FOT安装使用以及集成到Jenkins指导说明 + +## 1.介绍 + +A-FOT(automatic feedback-directed optimization tool)是一款用于提升编译器openEuler GCC自动反馈优化特性易用性的工具。 该工具的目标是让用户通过较少的配置即可自动完成反馈优化的相关步骤(包括采样、分析、优化等),降低自动反馈优化特性的使用难度,享受反馈优化带来的性能提升。 + +## 2.特别提醒 + +1.用户需要自行完成应用的构建脚本(build_script)和执行脚本(run_script)。本工具会使用构建脚本完成应用的构建,使用执行脚本启动被优化的应用 +2.本工具目前仅支持单实例应用优化,即应用在执行时只有一个进程 +3.用户需保证执行脚本启动的应用程序测试用例与实际生产环境行为相同,否则可能会导致负优化 + +## 3.环境依赖 + +1.编译器: openEuler GCC 10.3.1 +2.架构: x86_64 aarch64 + +## 4.安装 + +1.git clone https://gitee.com/openeuler/A-FOT.git +2.yum install -y A-FOT (仅支持openEuler 22.03 LTS) + +## 5.使用说明 + +### 1.填写配置项:在A-FOT根目录下找到a-fot.ini文件 + +```ini +# 文件和目录请使用绝对路径 + +# 优化模式(AutoFDO、AutoPrefetch、AutoBOLT、Auto_kernel_PGO(针对内核优化)) +opt_mode=AutoPrefetch +# 脚本工作目录(用来编译应用程序/存放profile、日志) +work_path=/opt +# 应用运行脚本路径 +run_script=/root/run.sh +# GCC路径(bin、lib的父目录) +gcc_path=/usr + +# AutoFDO、AutoPrefetch、AutoBOLT +# 针对应用的三种优化模式,请填写此部分配置 + +# 应用进程名 +application_name=test +# 二进制安装后可执行文件 +bin_file=/tmp/test +# 应用构建脚本路径 +build_script=/root/build.sh +# 最大二进制启动时间(单位:秒) +max_waiting_time=600 +# Perf采样时长(单位:秒) +perf_time=100 +# 检测是否优化成功(1=启用,0=禁用) +check_success=0 +# 构建模式 (Bear、Wrapper) +build_mode=Wrapper + +# auto_kernel_PGO +# 针对内核的优化模式,请填写此部分配置 + +# 内核PGO模式(arc=只启用arc profile,all=启用完整的PGO优化) +pgo_mode=all +# 执行阶段(1=编译插桩内核阶段,2=编译优化内核阶段) +pgo_phase=1 +# 内核源码目录(不指定则自动下载) +kernel_src=/opt/kernel +# 内核构建的本地名(将根据阶段添加"-pgoing"或"-pgoed"后缀) +kernel_name=kernel +# 内核编译选项(请确保选项修改正确合法,不会造成内核编译失败) +#CONFIG_...=y +# 重启前的时间目录(用于将同一套流程的日志存放在一起) +last_time= +# 内核源码的Makefile地址(用于不自动编译内核的场景) +makefile= +# 内核配置文件路径(用于不自动编译内核的场景) +kernel_config= +# 内核生成的原始profile目录(用于不自动编译内核的场景) +data_dir= +``` + +***参数补充说明*:** + +1)优化模式: + +A-FOT是一款用于提升编译器GCC for openEuler自动反馈优化特性的工具,支持以下三种模式: + +- AutoFDO + +- AutoPrefetch + +- AutoBOLT + + **说明:** + + - AutoFDO是PGO的简化部署版,使用perf替代插桩获取程序运行profile,受益优化点包括矢量化、循环展开、循环剥离等优化。 + - AutoPrefetch是增强版预取优化,根据Dcache访问、存取指令cache miss率,获取数据访问优化代码块并进行预取优化,同时优化预取提前量,建议和AutoFDO共同使用。 + - AutoBOLT是链接后二进制优化,对控制流复杂的程序具有显著的优化效果,主要优化包括BB重排、函数重排、冷热分区等优化,与AutoFDO、AutoPrefetch部分冲突。 + +2)构建模式 + +构建模式支持两种模式: + +- Wrapper + +- Bear + + **说明:** + + - 选择“Wrapper”构建模式,会使用A-FOT中的包装器编译。 + - 选择“Bear”构建模式,会进行两次编译。 + +### 6.启动优化: + +```shell +a-fot --config_file a-fot.ini +``` + +### 7.默认参数配置以a-fot.ini为基础,同时支持参数通过命令行灵活配置: + +```shell +# 命令格式为 a-fot [OPTION1 ARG1] [OPTION2 ARG2] +# 例如以优化模式为AutoFDO,GCC路径/usr,应用运行脚本路径/root/run.sh,构建模式为Bear,命令如下 +a-fot --opt_mode AutoFDO --gcc_path /usr --run_script /root/run.sh --build_mode Wrapper +``` + +详细命令行参数如下: + +```shell +Usage: a-fot [OPTION1 ARG1] [OPTION2 ARG2] [...] + +For perf mode:(针对应用) +--config_file Path of configuration file +--opt_mode Optimization modes (AutoFDO/AutoPrefetch/AutoBOLT) +--perf_time Perf sampling duration (unit: seconds) +--gcc_path Compiler gcc path +--app_name Application process name +--bin_file Executable binary file path +--build_script Application build script path +--work_path Script working directory (used to compile the application and store the profile) +--run_script Script path for running application +--max_waiting_time Maximum binary startup time (unit: seconds) +--check_success Check optimization result +--build_mode Execute build script mode (Wrapper/Bear) + +For kernel PGO mode:(针对内核) +--config_file Path of configuration file +--opt_mode Optimization mode (Auto_kernel_PGO) +--pgo_mode PGO mode (arc/all) +--pgo_phase Phase of kernel PGO (1/2) +--kernel_src Kernel source directory +--kernel_name Kernel local version name (will be appended with -pgoing or -pgoed) +--work_path Script working directory (used to store the profile and the log) +--run_script Script path for running application +--gcc_path Compiler gcc path +--CONFIG_... Kernel building configuration +--last_time Last time directory before rebooting (used to put log infos together) +-s Silent mode (reboot automatically after kernel installation) +-n Do not compile kernel automatically +--makefile Makefile path of kernel +--kernel_config Config file path of kernel +--data_dir Profile path generated by kernel +``` + +## 8.Jenkins流水线配置示例: + +以配置文件参数优化: + +```groovy +pipeline { + agent any + options { + timeout(time: 1, unit: 'HOURS') + } + stages{ + stage('A-FOT') { + agent { + label 'Linux_aarch64' + } + steps{ + sh 'a-fot --config_file a-fot.ini' + } + } + } +} +``` + +以命令参数优化: + +```groovy +pipeline { + agent any + options { + timeout(time: 1, unit: 'HOURS') + } + stages{ + stage('A-FOT') { + agent { + label 'Linux_aarch64' + } + steps{ + sh 'a-fot --opt_mode AutoFDO --gcc_path /usr --run_script /root/run.sh --build_mode Wrapper' + } + } + } +} +``` + -- Gitee