如何在 g++ 中使用配置文件引导优化?
另外,谁能给我指出一个关于这个主题的好教程?我找不到.
Also, can anyone point me to a good tutorial on the subject? I can't find any.
推荐答案
-fprofile-generate 将使用分析代码检测应用程序.如果在编译时知道这种使用模式,应用程序将在实际运行时记录可以提高性能的某些事件.可以记录分支、内联的可能性等,但我不确定 GCC 是如何实现这一点的.
-fprofile-generate will instrument the application with profiling code. The application will, while actually running, log certain events that could improve performance if this usage pattern was known at compile time. Branches, possibility for inlining, etc, can all be logged, but I'm not sure in detail how GCC implements this.
程序退出后,会将所有这些数据转储到 *.gcda 文件中,这些文件本质上是用于测试运行的日志数据.使用 -fprofile-use 标志重建应用程序后,GCC 在优化时会考虑 *.gcda 日志数据,通常会显着提高性能.当然,这取决于很多因素.
After the program exits, it will dump all this data into *.gcda files, which are essentially log data for a test run. After rebuilding the application with -fprofile-use flag, GCC will take the *.gcda log data into account when doing its optimizations, usually increasing the performance significantly. Of course, this depends on many factors.
相关文章