当前位置:网站首页>反馈式编译
反馈式编译
2022-06-12 16:43:00 【天涯路linux】
一、 反馈式编译
简介
PGO,即Profile-Guided Optimizations,反馈式优化。PGO是编译器的又一优化技术,PGO与其它的一些优化技术/选项有一个明显的区别是:PGO优化是分三步完成的,是一个动态的优化过程。
反馈优化过程:
- 步骤 1 编译器插桩编译,编译生成插桩的可执行文件。
- 步骤 2 运行插桩的可执行文件,生成反馈数据文件gcda,这些文件记录了程序中控制流图上边的执行次数。
- 步骤 3 编译器读取反馈数据文件,利用反馈优化,生成高性能的可执行文件。
以下优化受益于反馈数据:
寄存器分配,基本块重排,内联,循环展开,指令调度,冗余指令删除等。
说明:代码变更时,反馈数据需要重新生成。
基础选项
编译获得插桩版本二进制或者so
gcc main.c –fprofile-generate –o instrument.out
复制代码上板运行获取gcda反馈式编译数据
./instrument.out
复制代码根据反馈式数据重新编译
gcc main.c –fprofile-use –o new.out
复制代码二、 FGO
PGO是gcc原生的反馈编译优化方案, 通过插桩运行采样得到的gcda文件来指导第二次编译优化,而FGO针对gcda文件二进制属性,解决业务侧源码交付的痛点,profile文件使用文本的形式导入。两者的区别是FGO的profile文件可以通过适当的手动修改适配,但当前FGO未完全支持C++模块优化。
三、 softFDO
softFDO是通过原生插桩运行得到的采样数据转换成google开源gcov数据格式,通过auto-profile Pass遍将数据导入进行优化。两者的区别是PGO支持value profile, softFDO不支持;softFDO使用的auto-profile Pass边在优化时调用了early-inline操作
作者:掘金_陶嘉恒
链接:https://juejin.cn/post/6997231595610439687
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
边栏推荐
- STL——函数对象
- 890. 查找和替换模式 / 剑指 Offer II 080. 含有 k 个元素的组合
- Probation period and overtime compensation -- knowledge before and after entering the factory labor law
- key为断言的map是怎么玩的
- 男神女神投票源码 v5.5.21 投票源码
- \Begin{algorithm} notes
- The C programming language (version 2) notes / 8 UNIX system interfaces / 8.6 instances (directory list)
- mysql语句
- \Begin{algorithm} notes
- Uniapp壁纸小程序源码/双端微信抖音小程序源码
猜你喜欢

Canvas advanced functions (Part 2)

WebRTC 的音频网络对抗概述

博士申请 | 新加坡国立大学Xinchao Wang老师招收图神经网络方向博士/博后

redis. clients. jedis. exceptions. JedisDataException: NOAUTH Authentication required

【湖南大学】考研初试复试资料分享

pytorch和torchvision官方文档使用方法

修改自己电脑连接的路由器的配置网址192.168.1.1

2080虚拟机登录命令

薛定谔的日语学习小程序源码

Large scale real-time quantile calculation -- a brief history of quantitative sketches
随机推荐
双写一致性问题
Picture online collection and delivery system source code
并发三色标记法
CVPR 2022 | 元学习在图像回归任务的表现
Preprocessing command section 3
The C programming language (version 2) notes / 8 UNIX system interface / 8.3 open, create, close, unlink
Programmers broke the news: 3 job hopping in 4 years, and the salary has tripled! Netizen: the fist is hard
软件工程 学生信息管理系统 结构化的需求分析
"Shandong University project training" rendering engine system (8-END)
The C programming language (version 2) notes / 8 UNIX system interfaces / 8.6 instances (directory list)
The C programming language (version 2) notes / 8 UNIX system interface / 8.1 file descriptor
What is compound interest financial product?
每天5分钟玩转Kubernetes | 汇总
MySQL interview arrangement
uabntu的sudo
\Begin{algorithm} notes
博士申請 | 新加坡國立大學Xinchao Wang老師招收圖神經網絡方向博士/博後
JS using RSA encryption and decryption
[MySQL] Cartesian product - multi table query (detailed explanation)
Extract the new Chinese cross modal benchmark zero from 5billion pictures and texts, and Qihoo 360's new pre training framework surpasses many SOTAS