Skip to content

Conversation

@zhangbo9674
Copy link
Contributor

@zhangbo9674 zhangbo9674 commented Dec 29, 2022

PR types

Performance optimization

PR changes

Others

Describe

优化1:

依据gcov覆盖率分析工具,提升C++单测精准测试命中率。优化方式如下:
利用gcov覆盖率分析工具分析发现:一个不调用任何Paddle组件的C++单测统计出来的覆盖率分析结果表明其执行了很多Paddle文件。例如如下这个简单的C++单测:
#include "gtest/gtest.h" TEST(interface_test, type) { int a = 0; }
覆盖率统计结果如下:
图片
基于该现象,我们对精准测试流水线做如下优化:

  • 构造一个不调用任何Paddle组件的C++单测:simple_test,利用gcov进行覆盖率分析,统计出所有C++文件FNDA信息(FNDA信息:执行函数:调用测试)
  • 对所有Paddle框架C++单测进行FNDA分析的时候,消除掉与simple_test重叠的FNDA数据

经过测试,以variant_test为例,经过上述优化后,筛选到的与该单测相关的cc文件从767减少为0

优化2:

优化精准测试流水线 getFNDAFile 函数,加速覆盖率文件解析速度。以一个简单的 C++ 单测 variant_test 的 gcov 覆盖率文件为例,对比优化前后解析耗时:

  • 优化前:98s
  • 优化后:39s

@paddle-bot
Copy link

paddle-bot bot commented Dec 29, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

):
os.system('echo %s >> %s' % (message, fn_filename))
f.close()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码的优化思路是这样的吗?
首先把TN所在的空白行删掉,然后只遍历覆盖率文件中FNH不为0(函数总数被执行个数不为0的那一块代码),在原来的基础上删掉了对很多FNDA为0的无效遍历,从而减少了不必要的遍历,缩短了时间,达到pr所提到的优化效果?

@zhangbo9674 zhangbo9674 changed the title [CI-Precision]Speedup getFNDAFile [CI-Precision] Optimize precision test logic Dec 29, 2022
read testcase <<< $(echo "$line"|grep -oEi "\w+$")

if [["$testcase" == "simple_test"]]; then
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [["$testcase" == "simple_test"]] 需要改成if [[ "$testcase" == "simple_test" ]]这样把,不然会报错

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, tks!

Copy link
Contributor

@risemeup1 risemeup1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for optimizing precision test logic

@zhangbo9674 zhangbo9674 merged commit 3e8cec8 into PaddlePaddle:develop Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants