[cfe-dev] clang-rename performance oddness

Kirill Bobyrev via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 17 01:12:16 PDT 2016


Hi Miklos,

I had similar discussion with Manuel couple weeks ago.

This is what I have:

*Debug build*
kbobyrev at kbobyrev:~$ time ~/Documents/dev/build/Debug/llvm/bin/clang-rename
-offset=9298 -new-name=Options -i
~/Documents/dev/src/llvm/tools/clang/tools/extra/clang-rename/tool/ClangRename.cpp

real 1m11.103s
user 1m10.534s
sys 0m0.548s

*RelWithDebInfo build*
kbobyrev at kbobyrev:~$ time
~/Documents/dev/build/RelWithDebInfo/llvm/bin/clang-rename -offset=9298
-new-name=Options -i
~/Documents/dev/src/llvm/tools/clang/tools/extra/clang-rename/tool/ClangRename.cpp

real 0m7.830s
user 0m5.476s
sys 0m2.318

*Release build*
kbobyrev at kbobyrev:~$ time
~/Documents/dev/build/Release/llvm/bin/clang-rename -offset=9298
-new-name=Options -i
~/Documents/dev/src/llvm/tools/clang/tools/extra/clang-rename/tool/ClangRename.cpp

real 0m4.553s
user 0m4.364s
sys 0m0.184s

What Manuel pointed out, unless you are building in Release mode Clang AST
Parser is really really slow. Thus, we only saw performance problems in AST
parsing, clang-rename routine seemed OK for me at that point.

Are you sure you have 60+ seconds in RelWithDebInfo mode, not in Debug
mode? If you are, please send me some additional info about how to
reproduce the problem.

--
Kirill

On Tue, Aug 16, 2016 at 10:07 PM, Miklos Vajna via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> [ Resent this time without attaching a screenshot. ]
>
> I've recently tried to use clang-rename on a larger codebase
> (LibreOffice's core.git repo [1]), and while the tool works correctly, it's
> surprisingly slow.
>
> I've tried 3 actions:
>
> 1) Compiling a (somewhat random selected) file,
> sw/source/uibase/uiview/pview.cxx with clang++: it takes about 4 seconds
> on my machine.
>
> 2) Using LibreOffice's own simple rename tool [2] to rename 11 members
> of a class referenced in that translation unit: also about 4 seconds.
>
> 3) Doing the same with clang-rename: 76 seconds.
>
> So I expected that clang-rename does something stupid, but after
> building the LLVM codebase with -DCMAKE_BUILD_TYPE=RelWithDebInfo and
> used callgrind to see where time is spent, it seems that the time is
> mostly spent in clang::ParseAST().
>
> (One more thing I did not check is if -DLLVM_ENABLE_ASSERTIONS=ON is the
> source of that slowdown; but I doubt such a 19x slowdown is due to
> assertions being enabled.)
>
> I see no obvious silly in any of its callers, like calling it again and
> again inside a for() cycle or something like that. Any idea what might
> cause the 4 vs 76 seconds?
>
> I guess the problem is not specific to the above source file, but in
> case it's interesting, happy to write up and share precise, reproducible
> steps to trigger the problem.
>
> I'm not sure what's a good way to share a callgrind profile, but I've
> uploaded a kcachegrind screenshot[3]; what is a bit surprising to me is
> that the time (it seems) is spent in a single clang function that's
> called only once by clang-rename, and I guess the same function is also
> called by clang++.
>
> Any ideas how to debug such a problem?
>
> Thanks,
>
> Miklos
>
> [1] git clone git://anongit.freedesktop.org/libreoffice/core
> [2] https://cgit.freedesktop.org/libreoffice/contrib/dev-tools/
> tree/clang/rename.cxx
> [3] https://people.freedesktop.org/~vmiklos/2016/Screenshot_
> 20160816_215756.png
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



-- 
Best regards,
Kirill Bobyrev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160817/456b1bb6/attachment.html>


More information about the cfe-dev mailing list