当前位置:网站首页>Use GCC's PGO (profile guided optimization) to optimize the entire system
Use GCC's PGO (profile guided optimization) to optimize the entire system
2022-06-12 17:08:00 【Tianya road Linux】
inspire
It comes from the experiment made by megahard on its own server , No more nonsense, just go to the picture above
Microsoft's approach
Microsoft's approach
You can see the use of PGO The optimized kernel still has some performance improvements
zero 、 Premise
Want to use PGO Compile optimization , Yours gcc The compiler needs to turn on support pgo characteristic ,gentoo The system is as follows
sudo vim /etc/portage/make.conf:
USE="pgo"
sudo emerge gcc
One 、 kernel kernel The optimization of the
cd /usr/src/linux
sudo make clean
sudo make menuconfig:
CONFIG_DEBUG_FS=y
CONFIG_GCOV_KERNEL=y
CONFIG_GCOV_PROFILE_ALL=y
sudo make KCFLAGS=“-fprofile-dir=/kernel-pgo/”
Final installation kernel And update the grub
sudo make install
sudo grub-config -o /boot/grub/grub.cfg
Restart the system
sudo reboot
Then run the system under the new kernel for a while , Open various software such as browser 、mpv player 、cmus、 office 、 Compiling software 、 download 、 game 、steam wait ( I will run through all the software and scenarios of the daily system ), So that the kernel can collect enough profile data (gcov data )
# notes : Open the CONFIG_DEBUG_FS=y、CONFIG_GCOV_KERNEL=y Characteristic kernel Performance will be significantly reduced , But this pair of collections is used for PGO Optimization of the profile Data is necessary
kernel PGO Optimization of the profile The data is stored in /sys/kernel/debug/gcov/kernel-pgo/ Under the table of contents , There are many small files , The format is similar to "#usr#src#linux#arch#x86#crypto#aesni-intel_glue.gcda"
sudo cp -r /sys/kernel/debug/gcov/kernel-pgo/ /
cd /usr/src/linux
sudo make clean
sudo make menuconfig:
CONFIG_DEBUG_FS=n
CONFIG_GCOV_KERNEL=n
CONFIG_GCOV_PROFILE_ALL=n
sudo make KCFLAGS=“-fprofile-use -fprofile-dir=/kernel-pgo/ -fprofile-correction -Wno-coverage-mismatch -Wno-error=coverage-mismatch”
Final installation kernel And update the grub
sudo make install
sudo grub-config -o /boot/grub/grub.cfg
Restart the system
sudo reboot
Okay , Now you can experience PGO What is the performance of the optimized kernel , Open the game to test fps Well , Is it higher than the original kernel frame number ?
Add : Use Clang Of LTO Optimize compilation kernel
since kernel 5.12 The start kernel allows lto To optimize the , However, it is limited to support clang+llvm compiler , I won't support it gcc, So you have to install it first clang and llvm, as well as lld The linker . The steps are simple ——
sudo make LLVM=1 LLVM_IAS=1 menuconfig:
CONFIG_DEBUG_FS=n
CONFIG_GCOV_KERNEL=n
CONFIG_GCOV_PROFILE_ALL=n
CONFIG_LTO_CLANG_FULL=y
then
sudo make LLVM=1 LLVM_IAS=1
that will do .
# notes : at present clang Kernel is not supported gcov Optimize , So the above gcc Of pgo and clang Of lto You can only choose one of the two optimization schemes .
If you don't think the regular kernel can satisfy you , You can also try compiling it yourself xanmod The kernel project , Compared with the conventional kernel, it has done a lot of update optimization ( For example, open O3 Level compilation optimization )——
https://www.xanmod.org/www.xanmod.org/
# Click... On the web page “tarball” You can download it. xanmod Kernel source package .
Two 、 Of all program software in the whole system PGO Optimize
First you need to turn off portage Two security features of the build system
sudo vim /etc/portage/make.conf:
FEATURES="-sandbox -usersandbox"
Then add the following gcc Compile parameters
sudo vim /etc/portage/make.conf:
COMMON_FLAGS="$( Your own original compilation optimization parameters ) -fprofile-generate -fprofile-dir=/portage-pgo/"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
LDFLAGS="${COMMON_FLAGS} -Wl,-O3 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--sort-common -Wl,--strip-all -ljemalloc -Wl,-ljemalloc"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --ask --deep --verbose=y --load-average --keep-going"
sudo mkdir /portage-pgo/
Now start compiling the entire system
sudo emerge -e @world
Restart the system after compilation
sudo reboot
Then run the system under the new system for a period of time , Open various software such as browser 、mpv player 、cmus、 office 、 Compiling software 、 download 、 game 、steam wait ( I will run through all the software and scenarios of the daily system , Recommended 1-2 God ), To collect enough comprehensive profile data (gcov data ), Each program PGO Optimization of the profile The data is stored in /portage-pgo/ Under the table of contents
# notes : Open the -fprofile-generate The program performance of the feature will decrease significantly , But this pair of collections is used for PGO Optimization of the profile Data is necessary
Restart the system
sudo reboot
And then modify gcc Compile parameters
sudo vim /etc/portage/make.conf:
COMMON_FLAGS="$( Your own original compilation optimization parameters ) -fprofile-use -fprofile-dir=/portage-pgo/ -fprofile-correction -Wno-error=missing-profile"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
LDFLAGS="${COMMON_FLAGS} -Wl,-O3 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--sort-common -Wl,--strip-all -ljemalloc -Wl,-ljemalloc"
Compile the entire system again to use PGO Optimize ( Turn on pgo After optimization, the compilation speed will be greatly improved , It won't be as long as the last time )
sudo emerge -e @world
Restart the system after compilation
sudo reboot
Okay , Now you can experience PGO Comprehensive compilation optimization gentoo The system , Is it the ultimate performance ?
Use GCC Of PGO(Profile-guided Optimization) Optimize the whole system - You know
边栏推荐
- 2022-2028 global press dehydrator industry research and trend analysis report
- 有趣的 LD_PRELOAD
- \Begin{algorithm} notes
- Preprocessing command section 3
- redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required
- The R language uses the PDF function to save the visual image results to the PDF file, uses the PDF function to open the image device, uses the dev.off function to close the image device, and customiz
- Difference between big end mode and small end mode
- 怎么在公司里面做好测试工作(做好测试工作)
- [BSP video tutorial] stm32h7 video tutorial Issue 8: the last issue of the MDK theme, the new generation of debugging technologies event recorder and RTT, and using stm32cubemx to generate project tem
- Go的变量
猜你喜欢
[MySQL] internal connection, external connection and self connection (detailed explanation)
Dongfeng Yueda Kia, Tencent advertising and hero League mobile game professional league cooperate to build a new E-sports ecology
Swin transformer code explanation
云开发坤坤鸡乐盒微信小程序源码
CVPR 2022 | 元学习在图像回归任务的表现
RMI, JNDI, LDAP introduction +log4j vulnerability analysis
两位新晋Committer的“升级攻略”
Structural requirement analysis of software engineering student information management system
Qt开发高级进阶:初探qt + opengl
The significance of writing technology blog
随机推荐
丁总路由器设置以及401联网
R语言计算data.table在一个分组变量的值固定的情况下另外一个分组变量下指定数值变量的均值
Some minor problems and solutions encountered when using ubantu
(三)Golang - 数据类型
RMI, JNDI, LDAP introduction +log4j vulnerability analysis
Demande de doctorat | xinchao Wang, Université nationale de Singapour
D. master router setting and 401 networking
薛定谔的日语学习小程序源码
软件工程 学生信息管理系统 结构化的需求分析
Go的变量
MySQL transaction introduction and transaction isolation level
Sudo of uabntu
R语言使用epiDisplay包的aggregate.plot函数可视化每个子集的汇总统计信息(可视化基于单个分组下的阳性指标的概率值及其95%置信区间、基于折线图、仅仅适用于目标类别为二分类)
Fiddler抓包几种常用功能介绍(停止抓包、清空会话窗内容、过滤请求、解码、设置断点......)
Atlassian Confluence 远程代码执行漏洞(CVE-2022-26134)漏洞复现
R language calculates data Table specifies the mean value of a numeric variable when the value of one grouped variable is fixed and another grouped variable
[raspberry pie]: (IV) camera advanced
How to do a good job of testing in the company (do a good job of testing)
Play kubernetes every 5 minutes summary
博士申請 | 新加坡國立大學Xinchao Wang老師招收圖神經網絡方向博士/博後